mirror of
https://github.com/doocs/advanced-java.git
synced 2024-12-24 03:50:08 +08:00
feat: introduce giscus comment system (#292)
This commit is contained in:
parent
8a9f15ca32
commit
dd802a8de9
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -1 +1,3 @@
|
|||||||
*.html linguist-language=java
|
*.html linguist-language=java
|
||||||
|
*.css linguist-language=java
|
||||||
|
*.js linguist-language=java
|
@ -10,6 +10,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
|
||||||
<link rel="stylesheet" href="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify/lib/themes/vue.css" />
|
<link rel="stylesheet" href="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify/lib/themes/vue.css" />
|
||||||
<link rel="stylesheet" href="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify-darklight-theme@latest/dist/style.min.css" />
|
<link rel="stylesheet" href="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify-darklight-theme@latest/dist/style.min.css" />
|
||||||
|
<link rel="stylesheet" href="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify-giscus@1.0.0/dist/giscus.css">
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png" />
|
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png" />
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png" />
|
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png" />
|
||||||
<style>
|
<style>
|
||||||
|
36
main.js
36
main.js
@ -1,7 +1,9 @@
|
|||||||
|
const giscusTheme = () =>
|
||||||
|
localStorage.getItem('DARK_LIGHT_THEME') === 'dark' ? 'noborder_dark' : 'light';
|
||||||
|
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
name: 'advanced-java',
|
name: 'advanced-java',
|
||||||
repo: 'doocs/advanced-java',
|
repo: 'doocs/advanced-java',
|
||||||
lastModifiedText: '最近更新时间:',
|
|
||||||
maxLevel: 3,
|
maxLevel: 3,
|
||||||
auto2top: true,
|
auto2top: true,
|
||||||
coverpage: true,
|
coverpage: true,
|
||||||
@ -11,6 +13,7 @@ window.$docsify = {
|
|||||||
'/.*/.*/summary': 'summary.md',
|
'/.*/.*/summary': 'summary.md',
|
||||||
'/.*/summary.md': 'summary.md',
|
'/.*/summary.md': 'summary.md',
|
||||||
},
|
},
|
||||||
|
lastModifiedText: '最近更新时间:',
|
||||||
pagination: {
|
pagination: {
|
||||||
previousText: '上一篇',
|
previousText: '上一篇',
|
||||||
nextText: '下一篇',
|
nextText: '下一篇',
|
||||||
@ -68,7 +71,7 @@ window.$docsify = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const github = `[GitHub](${url})`;
|
const github = `[GitHub](${url})`;
|
||||||
const gitee = `[Gitee](${url.replace('github', 'gitee' )})`;
|
const gitee = `[Gitee](${url.replace('github', 'gitee')})`;
|
||||||
|
|
||||||
const editHtml = en
|
const editHtml = en
|
||||||
? `:memo: Edit on ${github} / ${gitee}\n`
|
? `:memo: Edit on ${github} / ${gitee}\n`
|
||||||
@ -108,6 +111,35 @@ window.$docsify = {
|
|||||||
const footer = `<footer><span>Copyright © 2018-${currentYear} <a href="https://github.com/doocs" target="_blank">Doocs</a>. All Rights Reserved.</footer>`;
|
const footer = `<footer><span>Copyright © 2018-${currentYear} <a href="https://github.com/doocs" target="_blank">Doocs</a>. All Rights Reserved.</footer>`;
|
||||||
return html + footer;
|
return html + footer;
|
||||||
});
|
});
|
||||||
|
hook.doneEach(() => {
|
||||||
|
const giscusScript = document.createElement('script');
|
||||||
|
giscusScript.type = 'text/javascript';
|
||||||
|
giscusScript.async = true;
|
||||||
|
giscusScript.setAttribute('src', 'https://giscus.app/client.js');
|
||||||
|
giscusScript.setAttribute('data-repo', 'doocs/advanced-java');
|
||||||
|
giscusScript.setAttribute('data-repo-id', 'MDEwOlJlcG9zaXRvcnkxNTE4MzQwNjI=');
|
||||||
|
giscusScript.setAttribute('data-mapping', 'number');
|
||||||
|
giscusScript.setAttribute('data-reactions-enabled', '1');
|
||||||
|
giscusScript.setAttribute('data-strict', '1');
|
||||||
|
giscusScript.setAttribute('data-emit-metadata', '0');
|
||||||
|
giscusScript.setAttribute('data-input-position', 'top');
|
||||||
|
giscusScript.setAttribute('crossorigin', 'anonymous');
|
||||||
|
giscusScript.setAttribute('data-term', '9');
|
||||||
|
giscusScript.setAttribute('data-lang', 'zh-CN');
|
||||||
|
giscusScript.setAttribute('data-theme', giscusTheme());
|
||||||
|
|
||||||
|
document
|
||||||
|
.getElementById('main')
|
||||||
|
.insertBefore(giscusScript, document.getElementById('main').lastChild);
|
||||||
|
|
||||||
|
document.getElementById('docsify-darklight-theme').addEventListener('click', () => {
|
||||||
|
const frame = document.querySelector('.giscus-frame');
|
||||||
|
frame.contentWindow.postMessage(
|
||||||
|
{ giscus: { setConfig: { theme: giscusTheme() } } },
|
||||||
|
'https://giscus.app',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
})
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user