forked from drowl87/hextra_mirror
fix: giscus theme and language display issues (#95)
* chore: minor update giscus template * fix: theme toggle should select all * chore: example configs for giscus * fix: language code in giscus
This commit is contained in:
parent
6a19ac31c0
commit
adf5a113fc
@ -26,6 +26,7 @@ languages:
|
||||
title: "Hextra テーマ"
|
||||
zh-cn:
|
||||
languageName: 简体中文
|
||||
languageCode: zh-CN
|
||||
weight: 3
|
||||
title: Hextra
|
||||
|
||||
@ -122,3 +123,20 @@ params:
|
||||
editURL:
|
||||
enable: true
|
||||
base: "https://github.com/imfing/hextra/edit/main/exampleSite/content"
|
||||
|
||||
comment:
|
||||
enable: false
|
||||
type: giscus
|
||||
|
||||
# https://giscus.app/
|
||||
giscus:
|
||||
repo: "imfing/hextra"
|
||||
repoId: "R_kgDOJ9fJag"
|
||||
category: "General"
|
||||
categoryId: "DIC_kwDOJ9fJas4CY7gW"
|
||||
# mapping: "pathname"
|
||||
# strict: 0
|
||||
# reactionsEnabled: 1
|
||||
# emitMetadata: 0
|
||||
# inputPosition: "top"
|
||||
# lang: "en"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{- with site.Params.comment.giscus -}}
|
||||
{{- $lang := site.Language.LanguageCode | default `en` -}}
|
||||
|
||||
{{- $lang = site.Language.Lang | default `en` -}}
|
||||
{{- with site.Params.comment.giscus -}}
|
||||
<script>
|
||||
/*
|
||||
* "preferred color scheme" theme in giscus works using "prefers-color-scheme" in media query.
|
||||
@ -40,9 +40,6 @@
|
||||
"data-theme": getGiscusTheme(),
|
||||
"data-lang": "{{ .lang | default $lang }}",
|
||||
"crossorigin": "anonymous",
|
||||
{{ if .lazyLoading -}}
|
||||
"data-loading": "lazy",
|
||||
{{ end -}}
|
||||
"async": "",
|
||||
};
|
||||
|
||||
@ -52,11 +49,12 @@
|
||||
document.getElementById('giscus').appendChild(giscusScript);
|
||||
|
||||
// Update giscus theme when theme switcher is clicked
|
||||
const toggle = document.querySelector('.theme-toggle');
|
||||
if (toggle) {
|
||||
toggle.addEventListener('click', setGiscusTheme);
|
||||
const toggles = document.querySelectorAll(".theme-toggle");
|
||||
if (toggles) {
|
||||
toggles.forEach(toggle => toggle.addEventListener('click', setGiscusTheme));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="giscus"></div>
|
||||
{{- end -}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user