summaryrefslogtreecommitdiffstats
path: root/themes/danix-xyz-hacker/layouts
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-15 17:25:14 +0200
committerDanilo M. <danix@danix.xyz>2026-04-15 17:25:14 +0200
commit7c8971eb481cea544987d4b9ddcb8064d9087766 (patch)
tree1c343e46262013a223bd817aeef4c35c8c1d9996 /themes/danix-xyz-hacker/layouts
parent231d29bf26820ca058dec57c06345943ca6dbbf2 (diff)
downloaddanixxyz-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/layouts')
-rw-r--r--themes/danix-xyz-hacker/layouts/partials/article-header.html23
1 files changed, 13 insertions, 10 deletions
diff --git a/themes/danix-xyz-hacker/layouts/partials/article-header.html b/themes/danix-xyz-hacker/layouts/partials/article-header.html
index 252d87a..10808f9 100644
--- a/themes/danix-xyz-hacker/layouts/partials/article-header.html
+++ b/themes/danix-xyz-hacker/layouts/partials/article-header.html
@@ -1,15 +1,14 @@
{{ $articleType := .Params.type | default "life" }}
{{ $typeConfig := .Site.Params.articleTypes }}
{{ $typeData := index $typeConfig $articleType }}
-{{ $isDark := strings.Contains (os.Getenv "THEME") "dark" }}
-{{ $color := cond $isDark $typeData.color_dark $typeData.color_light }}
<div class="mb-8 pb-8 border-b border-border">
<!-- Type badge -->
{{ if $typeData }}
<span
class="inline-flex items-center px-3 py-1 rounded text-sm font-semibold mb-4 transition-colors"
- style="color: {{ $color }}; background-color: {{ $color }}20;"
+ style="color: {{ $typeData.color_light }}; background-color: {{ $typeData.color_light }}20;"
+ data-theme-dark-color="{{ $typeData.color_dark }}"
>
{{ i18n $articleType }}
</span>
@@ -33,13 +32,17 @@
{{ end }}
<!-- Update date if different -->
- {{ if and .LastMod (ne .LastMod.Format "2006-01-02" .PublishDate.Format "2006-01-02") }}
- <div class="flex items-center gap-1">
- <i data-feather="edit-2" class="w-4 h-4"></i>
- <time datetime="{{ .LastMod.Format "2006-01-02T15:04:05Z07:00" }}">
- {{ .LastMod.Format "Jan 2, 2006" }}
- </time>
- </div>
+ {{ if .Lastmod }}
+ {{ $lastmodDate := .Lastmod.Format "2006-01-02" }}
+ {{ $pubDate := .PublishDate.Format "2006-01-02" }}
+ {{ if ne $lastmodDate $pubDate }}
+ <div class="flex items-center gap-1">
+ <i data-feather="edit-2" class="w-4 h-4"></i>
+ <time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">
+ {{ .Lastmod.Format "Jan 2, 2006" }}
+ </time>
+ </div>
+ {{ end }}
{{ end }}
<!-- Reading time -->