hextra icon indicating copy to clipboard operation
hextra copied to clipboard

Fix: giscus.html fails when country code is specified.

Open dogweather opened this issue 1 year ago • 6 comments

The problem is that the Giscus API fails when given data-lang of something like de-DE:

Screenshot 2024-04-15 at 15 40 00

This fix uses just the language tag, not the whole language code: https://gohugo.io/methods/site/language/#methods

With this fix:

Screenshot 2024-04-15 at 15 47 13

(live at https://forkful.ai/de/kotlin/good-coding-practices/ )

dogweather avatar Apr 15 '24 21:04 dogweather

Deploy Preview for hugo-hextra ready!

Name Link
Latest commit 27a70e4c122e0590248f0cb49767403f422d56a9
Latest deploy log https://app.netlify.com/sites/hugo-hextra/deploys/661dcc21350f64000885cbcf
Deploy Preview https://deploy-preview-358--hugo-hextra.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Apr 15 '24 21:04 netlify[bot]

Thanks for the PR. It makes sense.

I checked the list of available locales on giscus and noticed that zh-CN and zh-TW use mixed casing. With this change, the giscus will now use the lowercase zh-cn in our example site, which can be seen here: https://github.com/imfing/hextra/blob/be7e0d3f40f8f39d6323f13c3ae0ef253499ed5d/exampleSite/hugo.yaml#L25

Could you try changing zh-cn to zh-CN in the above link to see if everything still works correctly?

imfing avatar Apr 15 '24 22:04 imfing

Huh, will do. I'm guessing we need to make a special case for those. And yep, currently on my site, using just zh, it's broken.

dogweather avatar Apr 15 '24 23:04 dogweather

With this change, the giscus will now use the lowercase zh-cn in our example site, which can be seen here:

https://github.com/imfing/hextra/blob/be7e0d3f40f8f39d6323f13c3ae0ef253499ed5d/exampleSite/hugo.yaml#L25

Could you try changing zh-cn to zh-CN in the above link to see if everything still works correctly?

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 zh.

dogweather avatar Apr 16 '24 00:04 dogweather

I added special handling for Chinese. I tested it with:

languageCode: zh
languageCode: zh-cn
languageCode: zh-CN
languageCode: zh-tw
languageCode: zh-TW

dogweather avatar Apr 16 '24 00:04 dogweather

Awesome,appreciate it 👍 I was asking because of this issue https://github.com/imfing/hextra/issues/231

Will review it later today

imfing avatar Apr 16 '24 10:04 imfing