-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
misc: handling static and custom static overrides
- Loading branch information
1 parent
cbfd967
commit d751493
Showing
13 changed files
with
150 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Customize me */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Theme switcher - light/dark | ||
const themeSwitcher = { | ||
// Config | ||
_scheme: "auto", | ||
toggleButton: document.getElementById("theme-toggle"), | ||
rootAttribute: "data-theme", | ||
localStorageKey: "picoPreferredColorScheme", | ||
|
||
// Init | ||
init() { | ||
this.scheme = this.schemeFromLocalStorage; | ||
this.initToggle(); | ||
this.updateIcon(); | ||
}, | ||
|
||
// Get color scheme from local storage | ||
get schemeFromLocalStorage() { | ||
return window.localStorage?.getItem(this.localStorageKey) ?? this._scheme; | ||
}, | ||
|
||
// Preferred color scheme | ||
get preferredColorScheme() { | ||
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; | ||
}, | ||
|
||
// Init toggle | ||
initToggle() { | ||
this.toggleButton.addEventListener( | ||
"click", | ||
(event) => { | ||
event.preventDefault(); | ||
// Toggle scheme | ||
this.scheme = this.scheme === "dark" ? "light" : "dark"; | ||
this.updateIcon(); | ||
}, | ||
false | ||
); | ||
}, | ||
|
||
// Set scheme | ||
set scheme(scheme) { | ||
if (scheme == "auto") { | ||
this._scheme = this.preferredColorScheme; | ||
} else if (scheme == "dark" || scheme == "light") { | ||
this._scheme = scheme; | ||
} | ||
this.applyScheme(); | ||
this.schemeToLocalStorage(); | ||
}, | ||
|
||
// Get scheme | ||
get scheme() { | ||
return this._scheme; | ||
}, | ||
|
||
// Apply scheme | ||
applyScheme() { | ||
document.querySelector("html")?.setAttribute(this.rootAttribute, this.scheme); | ||
// staticBase is defined on content.html template | ||
document.querySelector("#highlightjs-theme")?.setAttribute("href", `${staticBase}/github-${this.scheme}.min.css`); | ||
}, | ||
|
||
// Store scheme to local storage | ||
schemeToLocalStorage() { | ||
window.localStorage?.setItem(this.localStorageKey, this.scheme); | ||
}, | ||
|
||
// Update icon based on the current scheme | ||
updateIcon() { | ||
if (this.scheme === "dark") { | ||
this.toggleButton.innerHTML = "☼"; // Sun icon for light mode | ||
} else { | ||
this.toggleButton.innerHTML = "☽"; // Moon icon for dark mode | ||
} | ||
}, | ||
}; | ||
|
||
// Init | ||
themeSwitcher.init(); | ||
|
||
// Menu | ||
|
||
const menuToggle = document.getElementById('menu-toggle'); | ||
const headerMenu = document.getElementById('header-menu'); | ||
|
||
menuToggle.addEventListener('click', function () { | ||
headerMenu.classList.toggle('active'); | ||
}); | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
User-agent: Mediapartners-Google | ||
Disallow: | ||
|
||
User-agent: * | ||
Allow: / |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.