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 テーマ"
|
title: "Hextra テーマ"
|
||||||
zh-cn:
|
zh-cn:
|
||||||
languageName: 简体中文
|
languageName: 简体中文
|
||||||
|
languageCode: zh-CN
|
||||||
weight: 3
|
weight: 3
|
||||||
title: Hextra
|
title: Hextra
|
||||||
|
|
||||||
@ -122,3 +123,20 @@ params:
|
|||||||
editURL:
|
editURL:
|
||||||
enable: true
|
enable: true
|
||||||
base: "https://github.com/imfing/hextra/edit/main/exampleSite/content"
|
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>
|
<script>
|
||||||
/*
|
/*
|
||||||
* "preferred color scheme" theme in giscus works using "prefers-color-scheme" in media query.
|
* "preferred color scheme" theme in giscus works using "prefers-color-scheme" in media query.
|
||||||
@ -40,9 +40,6 @@
|
|||||||
"data-theme": getGiscusTheme(),
|
"data-theme": getGiscusTheme(),
|
||||||
"data-lang": "{{ .lang | default $lang }}",
|
"data-lang": "{{ .lang | default $lang }}",
|
||||||
"crossorigin": "anonymous",
|
"crossorigin": "anonymous",
|
||||||
{{ if .lazyLoading -}}
|
|
||||||
"data-loading": "lazy",
|
|
||||||
{{ end -}}
|
|
||||||
"async": "",
|
"async": "",
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,11 +49,12 @@
|
|||||||
document.getElementById('giscus').appendChild(giscusScript);
|
document.getElementById('giscus').appendChild(giscusScript);
|
||||||
|
|
||||||
// Update giscus theme when theme switcher is clicked
|
// Update giscus theme when theme switcher is clicked
|
||||||
const toggle = document.querySelector('.theme-toggle');
|
const toggles = document.querySelectorAll(".theme-toggle");
|
||||||
if (toggle) {
|
if (toggles) {
|
||||||
toggle.addEventListener('click', setGiscusTheme);
|
toggles.forEach(toggle => toggle.addEventListener('click', setGiscusTheme));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="giscus"></div>
|
<div id="giscus"></div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user