mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 20:13:31 +08:00
Add reactionsEnabled and emitMetadata config for giscuss
+ Format code
This commit is contained in:
parent
fb2b92dbbf
commit
ecefb45ae1
@ -101,6 +101,8 @@ params:
|
||||
mapping:
|
||||
lightTheme:
|
||||
darkTheme:
|
||||
reactionsEnabled: 1
|
||||
emitMetadata: 0
|
||||
|
||||
widgets:
|
||||
enabled:
|
||||
@ -152,8 +154,8 @@ menu:
|
||||
weight: -100
|
||||
pre: home
|
||||
params:
|
||||
### For demonstration purpose, the home link will be open in a new tab
|
||||
newTab: true
|
||||
### For demonstration purpose, the home link will be open in a new tab
|
||||
newTab: true
|
||||
|
||||
related:
|
||||
includeNewer: true
|
||||
|
@ -5,40 +5,45 @@
|
||||
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="{{- default "light" .lightTheme -}}"
|
||||
data-mapping="{{- default `title` .mapping -}}"
|
||||
data-reactions-enabled="{{- default 1 .reactionsEnabled -}}"
|
||||
data-emit-metadata="{{- default 0 .emitMetadata -}}"
|
||||
data-theme="{{- default `light` .lightTheme -}}"
|
||||
crossorigin="anonymous"
|
||||
async
|
||||
></script>
|
||||
<script>
|
||||
|
||||
function setGiscusTheme(theme) {
|
||||
let giscus = document.querySelector('iframe.giscus-frame');
|
||||
if (giscus) {
|
||||
giscus.contentWindow.postMessage(
|
||||
{ giscus: { setConfig: { theme: theme } } },
|
||||
{
|
||||
giscus: {
|
||||
setConfig: {
|
||||
theme: theme
|
||||
}
|
||||
}
|
||||
},
|
||||
"https://giscus.app"
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
(function(){
|
||||
const head = document.getElementsByTagName("html")[0];
|
||||
|
||||
addEventListener('message', handler);
|
||||
addEventListener('message', (e) => {
|
||||
if (event.origin !== 'https://giscus.app') return;
|
||||
handler()
|
||||
});
|
||||
window.addEventListener('onColorSchemeChange', handler);
|
||||
|
||||
function handler() {
|
||||
if (head.getAttribute("data-scheme") == "light") {
|
||||
if (document.documentElement.dataset.scheme === "light") {
|
||||
setGiscusTheme('{{- default "light" .lightTheme -}}');
|
||||
} else {
|
||||
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
|
||||
};
|
||||
};
|
||||
}());
|
||||
|
||||
</script>
|
||||
{{- end -}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user