diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-11-03 20:08:36 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-11-03 20:08:36 +0300 |
commit | 59c7d4567380d1a9c80e96eb958fdbdd512ce006 (patch) | |
tree | 65410cfc10dbc7d060ec23be110662d9b7f6b0e9 /themes/hugo-theme-stack/layouts/partials/comments/provider/giscus.html |
новая жизнь блога
Diffstat (limited to 'themes/hugo-theme-stack/layouts/partials/comments/provider/giscus.html')
-rw-r--r-- | themes/hugo-theme-stack/layouts/partials/comments/provider/giscus.html | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/themes/hugo-theme-stack/layouts/partials/comments/provider/giscus.html b/themes/hugo-theme-stack/layouts/partials/comments/provider/giscus.html new file mode 100644 index 0000000..97fbb77 --- /dev/null +++ b/themes/hugo-theme-stack/layouts/partials/comments/provider/giscus.html @@ -0,0 +1,52 @@ +{{- 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-strict="{{- default 0 .strict -}}" + data-reactions-enabled="{{- default 1 .reactionsEnabled -}}" + data-emit-metadata="{{- default 0 .emitMetadata -}}" + data-input-position="{{- default `top` .inputPosition -}}" + data-theme="{{- default `light` .lightTheme -}}" + data-lang="{{- default (default `en` $.Language.LanguageCode) .lang -}}" + data-loading="{{- .loading -}}" + crossorigin="anonymous" + async +></script> +<script> + function setGiscusTheme(theme) { + let giscus = document.querySelector("iframe.giscus-frame"); + if (giscus) { + giscus.contentWindow.postMessage( + { + giscus: { + setConfig: { + theme: theme, + }, + }, + }, + "https://giscus.app" + ); + } + } + + (function () { + addEventListener("message", (e) => { + if (event.origin !== "https://giscus.app") return; + handler(); + }); + window.addEventListener("onColorSchemeChange", handler); + + function handler() { + if (document.documentElement.dataset.scheme === "light") { + setGiscusTheme('{{- default "light" .lightTheme -}}'); + } else { + setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}'); + } + } + })(); +</script> +{{- end -}} |