mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-30 04:23:30 +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:
|
mapping:
|
||||||
lightTheme:
|
lightTheme:
|
||||||
darkTheme:
|
darkTheme:
|
||||||
|
reactionsEnabled: 1
|
||||||
|
emitMetadata: 0
|
||||||
|
|
||||||
widgets:
|
widgets:
|
||||||
enabled:
|
enabled:
|
||||||
|
@ -5,40 +5,45 @@
|
|||||||
data-repo-id="{{- .repoID -}}"
|
data-repo-id="{{- .repoID -}}"
|
||||||
data-category="{{- .category -}}"
|
data-category="{{- .category -}}"
|
||||||
data-category-id="{{- .categoryID -}}"
|
data-category-id="{{- .categoryID -}}"
|
||||||
data-mapping="{{- default "title" .mapping -}}"
|
data-mapping="{{- default `title` .mapping -}}"
|
||||||
data-reactions-enabled="1"
|
data-reactions-enabled="{{- default 1 .reactionsEnabled -}}"
|
||||||
data-emit-metadata="0"
|
data-emit-metadata="{{- default 0 .emitMetadata -}}"
|
||||||
data-theme="{{- default "light" .lightTheme -}}"
|
data-theme="{{- default `light` .lightTheme -}}"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
async
|
async
|
||||||
></script>
|
></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function setGiscusTheme(theme) {
|
function setGiscusTheme(theme) {
|
||||||
let giscus = document.querySelector('iframe.giscus-frame');
|
let giscus = document.querySelector('iframe.giscus-frame');
|
||||||
if (giscus) {
|
if (giscus) {
|
||||||
giscus.contentWindow.postMessage(
|
giscus.contentWindow.postMessage(
|
||||||
{ giscus: { setConfig: { theme: theme } } },
|
{
|
||||||
|
giscus: {
|
||||||
|
setConfig: {
|
||||||
|
theme: theme
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"https://giscus.app"
|
"https://giscus.app"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
const head = document.getElementsByTagName("html")[0];
|
addEventListener('message', (e) => {
|
||||||
|
if (event.origin !== 'https://giscus.app') return;
|
||||||
addEventListener('message', handler);
|
handler()
|
||||||
|
});
|
||||||
window.addEventListener('onColorSchemeChange', handler);
|
window.addEventListener('onColorSchemeChange', handler);
|
||||||
|
|
||||||
function handler() {
|
function handler() {
|
||||||
if (head.getAttribute("data-scheme") == "light") {
|
if (document.documentElement.dataset.scheme === "light") {
|
||||||
setGiscusTheme('{{- default "light" .lightTheme -}}');
|
setGiscusTheme('{{- default "light" .lightTheme -}}');
|
||||||
} else {
|
} else {
|
||||||
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
|
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user