mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 20:13:31 +08:00
giscus
This commit is contained in:
parent
f07d5dc515
commit
2be9c55b5b
@ -93,6 +93,15 @@ params:
|
|||||||
path:
|
path:
|
||||||
lang:
|
lang:
|
||||||
|
|
||||||
|
giscus:
|
||||||
|
repo:
|
||||||
|
repoID:
|
||||||
|
category:
|
||||||
|
categoryID:
|
||||||
|
mapping:
|
||||||
|
lightTheme:
|
||||||
|
darkTheme:
|
||||||
|
|
||||||
widgets:
|
widgets:
|
||||||
enabled:
|
enabled:
|
||||||
- search
|
- search
|
||||||
@ -159,7 +168,7 @@ related:
|
|||||||
|
|
||||||
markup:
|
markup:
|
||||||
tableOfContents:
|
tableOfContents:
|
||||||
endLevel: 4
|
endLevel: 0
|
||||||
ordered: true
|
ordered: true
|
||||||
startLevel: 2
|
startLevel: 2
|
||||||
highlight:
|
highlight:
|
||||||
|
35
layouts/partials/comments/provider/giscus.html
Normal file
35
layouts/partials/comments/provider/giscus.html
Normal 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 -}}
|
Loading…
Reference in New Issue
Block a user