26 lines
No EOL
866 B
JavaScript
26 lines
No EOL
866 B
JavaScript
const $ = x => Array.from(document.querySelectorAll(x));
|
|
const $$ = x => Array.from(document.querySelector(x));
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Initialize Gravatar if available
|
|
if (typeof Gravatar !== 'undefined' && typeof Gravatar.init === 'function') {
|
|
Gravatar.init();
|
|
}
|
|
|
|
|
|
const themeToggleBtn = document.getElementById('theme-toggle-btn');
|
|
if (themeToggleBtn) {
|
|
themeToggleBtn.addEventListener('click', function() {
|
|
const root = document.documentElement;
|
|
if (root.classList.contains("dark")) {
|
|
root.classList.remove("dark");
|
|
root.setAttribute("data-theme", "light");
|
|
localStorage.setItem("theme", "light");
|
|
} else {
|
|
root.classList.add("dark");
|
|
root.setAttribute("data-theme", "dark");
|
|
localStorage.setItem("theme", "dark");
|
|
}
|
|
});
|
|
}
|
|
}); |