diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-17 11:47:04 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-17 11:47:04 +0200 |
| commit | c353452c544a3184ec66e05fa1743a592543a4d0 (patch) | |
| tree | 833fd7865f89a452a2c48e425712862827a7eb7f /themes/danix-xyz-hacker/layouts | |
| parent | 4ea2790206ca925bcf810c3b10d8c18e44015c61 (diff) | |
| download | danixxyz-c353452c544a3184ec66e05fa1743a592543a4d0.tar.gz danixxyz-c353452c544a3184ec66e05fa1743a592543a4d0.zip | |
fix: use client-side language detection for 404 navigation links
Added window.currentLang detection based on request URL path to correctly
route 404 page navigation links for Italian and English versions. Created
notFoundNav() Alpine component to dynamically compute language-aware links
based on detected language.
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/404.html | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/themes/danix-xyz-hacker/layouts/404.html b/themes/danix-xyz-hacker/layouts/404.html index efae232..0fb6c9a 100644 --- a/themes/danix-xyz-hacker/layouts/404.html +++ b/themes/danix-xyz-hacker/layouts/404.html @@ -1,5 +1,10 @@ {{ define "main" }} +<!-- Detect language from current URL --> +<script> +window.currentLang = window.location.pathname.startsWith('/it/') ? 'it' : 'en'; +</script> + <!-- Pass articles data to JavaScript for Alpine.js --> <script> window.articlesData = [ @@ -76,22 +81,14 @@ window.articlesData = [ </div> <!-- Navigation Links --> - <div class="space-y-4 flex flex-col items-center mb-12"> - {{ $lang := "en" }} - {{ if in .Permalink "/it/" }} - {{ $lang = "it" }} - {{ end }} - {{ $prefix := "" }} - {{ if eq $lang "it" }} - {{ $prefix = "/it" }} - {{ end }} - <a href="{{ $prefix }}/" class="btn btn-primary"> + <div class="space-y-4 flex flex-col items-center mb-12" x-data="notFoundNav()"> + <a :href="homeLink" class="btn btn-primary"> {{ i18n "goHome" }} </a> - <a href="{{ $prefix }}/articles/" class="btn btn-secondary"> + <a :href="articlesLink" class="btn btn-secondary"> {{ i18n "browseArticles" }} </a> - <a href="{{ $prefix }}/is/here/" class="btn btn-outline"> + <a :href="contactLink" class="btn btn-outline"> {{ i18n "contactSupport" }} </a> </div> |
