rhazdon / hugo-theme-hello-friend-ng

Pretty basic theme for Hugo that covers all of the essentials. All you have to do is start typing!
https://github.com/rhazdon/hugo-theme-hello-friend-ng/
Other
1.45k stars 764 forks source link

Fix theme flickering/flashing during pages loading #438

Closed ttybitnik closed 12 months ago

ttybitnik commented 1 year ago

When an user has opposite themes for their OS and the website, like OS dark and website light, it generates a flickering behaviour during loadings while browsing the website.

This fix this bug introducing a single line js inside the <head> to update the data-theme if there is a local theme defined by the user. Since this behaviour only happens when the user can toggle the theme, the single line script main_block.js is only deployed if the website config has the EnableThemeToggle set.

This addresses issue #429.

Tested locally and online. Working perfectly.