1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-21 05:41:17 -04:00

update server-side sitemap.xml code

This commit is contained in:
2022-05-07 20:47:14 -04:00
parent d8363d131a
commit 00d497b69b
7 changed files with 79 additions and 61 deletions

View File

@@ -9,14 +9,12 @@ export const clientScript = () => {
var light = "light";
var dark = "dark";
var newTheme;
// user's saved preference
var pref = window.localStorage.getItem("__STORAGE_KEY__");
// map of theme -> classname
var classNames = "__CLASS_NAMES__";
// the list of <html>'s current class(es)...
var classList = document.documentElement.classList;
// ...from which `classNames` are removed to start fresh
classList.remove(classNames[light], classNames[dark]);
// map of theme -> classname
var classNames = "__CLASS_NAMES__";
// user's saved preference
var pref = window.localStorage.getItem("__STORAGE_KEY__");
if (pref === light || pref === dark) {
// simply restore the local storage preference
@@ -27,7 +25,9 @@ export const clientScript = () => {
newTheme = window.matchMedia("__MEDIA_QUERY__").matches ? dark : light;
}
// FINALLY set the root class
// remove both `classNames` to start fresh...
classList.remove(classNames[light], classNames[dark]);
// ...and then FINALLY set the root class
classList.add(classNames[newTheme]);
} catch (error) {}
};