From 546bcc2e2670325e9ee7433ecd8c20b6786ceec8 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sun, 24 Aug 2025 23:06:14 +0200 Subject: [PATCH] fix(giscus): theme and language (#783) * fix(giscuss): system theme * fix(giscuss): language * fix(giscuss): theme switching * chore: remove confusing comment * fix(giscuss): use a uniq ID * chore: remove useless function * chore: use extra language code * chore: add comment about hash * Update layouts/_partials/components/giscus.html --------- Co-authored-by: Xin <5097752+imfing@users.noreply.github.com> --- exampleSite/hugo.yaml | 2 +- layouts/_partials/components/giscus.html | 75 ++++++++++++++---------- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index 79ecca0..4dd4a98 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -31,7 +31,7 @@ languages: title: هگزترا ja: languageName: 日本語 - languageCode: ja + languageCode: ja-JP weight: 3 title: Hextra zh-cn: diff --git a/layouts/_partials/components/giscus.html b/layouts/_partials/components/giscus.html index 73bac3e..869b616 100644 --- a/layouts/_partials/components/giscus.html +++ b/layouts/_partials/components/giscus.html @@ -1,40 +1,47 @@ -{{- $lang := site.Language.LanguageCode | default `en` -}} +{{- $lang := site.Language.Lang | default `en` -}} +{{- if hasPrefix $lang "zh" -}} + {{- /* See: https://github.com/giscus/giscus/tree/main/locales */}} + {{- $lang = site.Language.LanguageCode | default `zh-CN` -}} +{{- end -}} {{- with site.Params.comments.giscus -}} -
+
{{- else -}} {{ warnf "giscus is not configured" }} {{- end -}}