mirror of
https://github.com/tiennm99/bonsai.git
synced 2026-05-23 06:24:26 +00:00
a1dc82f213
Minimalist Hugo theme for link-in-bio pages, inspired by Linktree and Japanese bonsai aesthetics. - Single-page bio with avatar, tagline, bio, and links - Data-driven via [params] in hugo.toml — no content files needed - Light/dark mode via prefers-color-scheme + optional toggle - Inline SVG icon set (github, globe, mail, twitter, linkedin, etc) - Zero JS by default; opt-in theme toggle script - exampleSite for local development
18 lines
607 B
JavaScript
18 lines
607 B
JavaScript
// Optional: enable via params.themeToggle = true in hugo.toml
|
|
// Persists user preference and overrides system theme.
|
|
(function () {
|
|
const KEY = 'bonsai-theme';
|
|
const root = document.documentElement;
|
|
const saved = localStorage.getItem(KEY);
|
|
if (saved === 'light' || saved === 'dark') root.dataset.theme = saved;
|
|
|
|
const btn = document.querySelector('[data-bonsai-theme-toggle]');
|
|
if (!btn) return;
|
|
|
|
btn.addEventListener('click', () => {
|
|
const current = root.dataset.theme === 'dark' ? 'light' : 'dark';
|
|
root.dataset.theme = current;
|
|
localStorage.setItem(KEY, current);
|
|
});
|
|
})();
|