summaryrefslogtreecommitdiffstats
path: root/layouts/partials/header.html
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
committerDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
commit631547a75142326a7c71bdf123e1475217a5ad73 (patch)
treef3cfef6b3c5b42bf626fc823ddcf63b8dcf4cdbb /layouts/partials/header.html
parent77ccbe72fad5a4870185fff374f75471c16a9043 (diff)
downloaddanixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.tar.gz
danixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.zip
chore: replace with extracted danix.xyz-hacker theme (danix2-hugo-theme)
Diffstat (limited to 'layouts/partials/header.html')
-rw-r--r--layouts/partials/header.html94
1 files changed, 94 insertions, 0 deletions
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
new file mode 100644
index 0000000..914e645
--- /dev/null
+++ b/layouts/partials/header.html
@@ -0,0 +1,94 @@
+<header class="fixed top-0 left-0 right-0 z-50 frosted-bar border-b">
+ <nav class="container mx-auto px-4 py-4 flex items-center justify-between">
+ <!-- Logo and Site Name -->
+ {{ $homeLink := "/" }}
+ {{ if eq .Lang "it" }}
+ {{ $homeLink = "/it/" }}
+ {{ end }}
+ <a href="{{ $homeLink }}" class="flex items-center gap-2 hover:opacity-80 transition-opacity">
+ <img src="/images/lampD.png" alt="Logo" style="width: 40px; height: 40px; max-width: none;" class="flex-shrink-0">
+ <span class="hidden md:inline font-bold text-lg text-accent font-oxanium">danix.xyz</span>
+ </a>
+
+ <!-- Desktop menu (hidden on mobile) -->
+ <div class="hidden md:flex items-center gap-8">
+ {{ $currentPath := strings.TrimSuffix "/" .RelPermalink }}
+ {{ range .Site.Menus.main }}
+ {{ $menuPath := strings.TrimSuffix "/" .URL }}
+ {{ $isActive := eq $menuPath $currentPath }}
+ <a
+ href="{{ .URL }}"
+ class="text-sm transition-colors {{ if $isActive }}text-accent font-bold{{ else }}hover:text-accent{{ end }}"
+ {{ if $isActive }}aria-current="page"{{ end }}
+ >
+ {{ i18n .Name }}
+ </a>
+ {{ end }}
+ </div>
+
+ <!-- Right side controls: Search, Language, Theme, Menu -->
+ <div class="flex items-center gap-4 md:gap-6">
+ <!-- Search button (desktop only) -->
+ <button
+ x-data
+ @click="$dispatch('open-search')"
+ aria-label="{{ i18n "searchArticles" }}"
+ class="hidden md:flex p-2 rounded hover:bg-surface transition-colors focus:outline-none focus:ring-2 focus:ring-accent"
+ >
+ <i data-feather="search" class="w-5 h-5" aria-hidden="true"></i>
+ </button>
+
+ <!-- Language switcher (desktop) -->
+ <div class="hidden md:flex gap-2">
+ {{ $currentLang := .Page.Language }}
+ {{ $currentPath := .RelPermalink }}
+ {{ range .Site.Languages }}
+ {{ $langCode := .Lang }}
+ {{ $langName := .LanguageName }}
+ {{ $current := eq $langCode $currentLang }}
+ <!-- Build the translated URL by replacing language prefix -->
+ {{ $url := $currentPath }}
+ {{ if eq $langCode "en" }}
+ {{ if hasPrefix $currentPath "/it/" }}
+ {{ $url = strings.TrimPrefix "/it" $currentPath }}
+ {{ end }}
+ {{ else }}
+ {{ if not (hasPrefix $currentPath "/it/") }}
+ {{ $url = printf "/it%s" $currentPath }}
+ {{ end }}
+ {{ end }}
+ <a
+ href="{{ $url }}"
+ class="px-2 py-1 text-sm rounded transition-colors {{ if $current }}bg-accent text-white{{ else }}hover:bg-surface{{ end }}"
+ >
+ {{ $langName }}
+ </a>
+ {{ end }}
+ </div>
+
+ <!-- Theme toggle button -->
+ <button
+ id="theme-toggle"
+ aria-label="{{ i18n "toggleTheme" }}"
+ class="p-2 rounded hover:bg-surface transition-colors"
+ >
+ <i id="theme-icon-sun" data-feather="sun" class="w-5 h-5" aria-hidden="true"></i>
+ <i id="theme-icon-moon" data-feather="moon" class="w-5 h-5" aria-hidden="true"></i>
+ </button>
+
+ <!-- Hamburger menu button (mobile only) -->
+ <button
+ x-data
+ @click="$dispatch('toggle-menu')"
+ aria-label="{{ i18n "toggleMenu" }}"
+ aria-controls="hamburger-menu"
+ class="md:hidden p-2 rounded hover:bg-surface transition-colors"
+ >
+ <i data-feather="menu" class="w-5 h-5"></i>
+ </button>
+ </div>
+ </nav>
+
+ <!-- Mobile hamburger overlay menu -->
+ {{ partial "hamburger-menu.html" . }}
+</header>