This commit is contained in:
zhixuan 2021-08-14 14:16:52 +09:00
parent f07d5dc515
commit 2be9c55b5b
No known key found for this signature in database
GPG Key ID: 05D14AD50C51A06F
2 changed files with 45 additions and 1 deletions

View File

@ -93,6 +93,15 @@ params:
path:
lang:
giscus:
repo:
repoID:
category:
categoryID:
mapping:
lightTheme:
darkTheme:
widgets:
enabled:
- search
@ -159,7 +168,7 @@ related:
markup:
tableOfContents:
endLevel: 4
endLevel: 0
ordered: true
startLevel: 2
highlight:

View File

@ -0,0 +1,35 @@
{{- with .Site.Params.comments.giscus -}}
<script
src="https://giscus.app/client.js"
data-repo="{{- .repo -}}"
data-repo-id="{{- .repoID -}}"
data-category="{{- .category -}}"
data-category-id="{{- .categoryID -}}"
data-mapping="{{- default "title" .mapping -}}"
data-reactions-enabled="1"
data-emit-metadata="0"
data-theme="{{- .lightTheme -}}"
crossorigin="anonymous"
async
></script>
<script>
const light = "{{- .lightTheme -}}";
const dark = "{{- .darkTheme -}}";
const head = document.getElementsByTagName("html")[0];
function changeTheme(theme) {
const iframe = document.querySelector('iframe.giscus-frame');
iframe.contentWindow.postMessage(
{ giscus: { setConfig: { theme: theme } } },
"https://giscus.app"
);
}
window.onload = function() {
if (head.getAttribute("data-scheme") == "dark") {
console.log("dark");
changeTheme(dark);
}
}
</script>
{{- end -}}