diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-15 17:25:14 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-15 17:25:14 +0200 |
| commit | 7c8971eb481cea544987d4b9ddcb8064d9087766 (patch) | |
| tree | 1c343e46262013a223bd817aeef4c35c8c1d9996 /themes/danix-xyz-hacker/assets/js | |
| parent | 231d29bf26820ca058dec57c06345943ca6dbbf2 (diff) | |
| download | danixxyz-7c8971eb481cea544987d4b9ddcb8064d9087766.tar.gz danixxyz-7c8971eb481cea544987d4b9ddcb8064d9087766.zip | |
Fix Hugo v0.160 compatibility: remove os.Getenv and fix template syntax
- Remove os.Getenv("THEME") call that violates security policy
- Use CSS variables and data attributes for theme-aware badge colors
- Update theme-toggle.js to update badge colors on theme switch
- Fix .LastMod → .Lastmod (correct API)
- Fix template syntax for date comparison in article-header.html
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'themes/danix-xyz-hacker/assets/js')
| -rw-r--r-- | themes/danix-xyz-hacker/assets/js/theme-toggle.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/themes/danix-xyz-hacker/assets/js/theme-toggle.js b/themes/danix-xyz-hacker/assets/js/theme-toggle.js index 97ed1ce..3a4fda2 100644 --- a/themes/danix-xyz-hacker/assets/js/theme-toggle.js +++ b/themes/danix-xyz-hacker/assets/js/theme-toggle.js @@ -19,6 +19,20 @@ document.addEventListener('DOMContentLoaded', function() { // Add the new theme class htmlElement.classList.add(`theme-${newTheme}`); + // Update article type badge colors + const badges = document.querySelectorAll('[data-theme-dark-color]'); + badges.forEach(badge => { + if (newTheme === 'dark') { + const darkColor = badge.getAttribute('data-theme-dark-color'); + badge.style.color = darkColor; + badge.style.backgroundColor = darkColor + '20'; + } else { + const lightColor = badge.style.color; // Already set to light in HTML + badge.style.color = lightColor; + // backgroundColor stays as is (light color with opacity) + } + }); + // Persist to localStorage localStorage.setItem('theme', newTheme); |
