-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: giscus.html fails when country code is specified. #358
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for hugo-hextra ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thanks for the PR. It makes sense. I checked the list of available locales on giscus and noticed that Line 25 in be7e0d3
Could you try changing |
Huh, will do. I'm guessing we need to make a special case for those. And yep, currently on my site, using just |
I'm confused, sorry. With my change, it will just use the first two letters of the code. Here's my debug output I verified this with: ".Language.Lang": "zh"
".Language.LanguageCode": "zh-CN" And that currently breaks because giscus doesn't have i18n support for simple |
I added special handling for Chinese. I tested it with: languageCode: zh languageCode: zh-cn languageCode: zh-CN languageCode: zh-tw languageCode: zh-TW |
Awesome,appreciate it 👍 Will review it later today |
Giscus uses the geophraphical language code for these. | ||
See: https://github.com/giscus/giscus/tree/main/locales | ||
*/}} | ||
{{ if eq $giscus_lang "zh" }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, $giscus_lang
could also be zh-cn
, so it's better to use hasPrefix
instead of eq
.
@@ -1,4 +1,26 @@ | |||
{{- $lang := site.Language.LanguageCode | default `en` -}} | |||
{{ $default_chinese := "zh-CN" }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just inline this $default_chinese
, or move it inside the if block?
The problem is that the Giscus API fails when given
data-lang
of something likede-DE
:This fix uses just the language tag, not the whole language code: https://gohugo.io/methods/site/language/#methods
With this fix:
(live at https://forkful.ai/de/kotlin/good-coding-practices/ )