Because the JS script that handles the dark mode setting (via localStorage) is located after all other content, there's a small window where the page is rendered with default theme settings.
This PR fixes this behaviour by moving the script up to the first child of the body. I've also moved the toggleDarkMode inside the script, so the dark mode logic is all in one place.
Because the JS script that handles the dark mode setting (via localStorage) is located after all other content, there's a small window where the page is rendered with default theme settings.
This causes the page to flicker:
https://github.com/odin-lang/odin-lang.org/assets/18446907/85090484-6cdb-406c-9b4a-cebad8885eeb
This PR fixes this behaviour by moving the script up to the first child of the body. I've also moved the
toggleDarkMode
inside the script, so the dark mode logic is all in one place.