♻️ refactor: use const in theme initialization

Refactor the theme initialization script to use 'const' instead of 'let'
for the 'currentTheme' variable, as the value is not expected to change
after initialization.

This makes the code more clear and prevents accidental
re-assignment.
This commit is contained in:
welpo 2023-04-28 16:38:46 +02:00
parent 1efb0330e3
commit 9512bbb194
No known key found for this signature in database
GPG Key ID: A2F978CF4EC1F5A6
2 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
(function () { (function () {
let currentTheme = localStorage.getItem('theme'); const currentTheme = localStorage.getItem('theme');
if (currentTheme) { if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme); document.documentElement.setAttribute('data-theme', currentTheme);
} else { } else {

View File

@ -1 +1 @@
!function(){let e=localStorage.getItem("theme");if(e)document.documentElement.setAttribute("data-theme",e);else{let t=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.setAttribute("data-theme",t?"dark":"light")}}(); !function(){const e=localStorage.getItem("theme");if(e)document.documentElement.setAttribute("data-theme",e);else{const t=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.setAttribute("data-theme",t?"dark":"light")}}();