Submenu URL localization

This commit is contained in:
Tobias 2023-10-09 01:17:21 +02:00
parent a1a92b0145
commit 7b0e81b43b
Signed by: tobigr
GPG Key ID: 1081A7AAB3E37791
3 changed files with 14 additions and 22 deletions

View File

@ -138,33 +138,23 @@ menu:
- identifier: foundation - identifier: foundation
name: Foundation name: Foundation
url: /about/foundation/ url: /about/foundation/
params:
url_en: /en/become-a-member/
url_de: /de/mitglied-werden/
weight: 10 weight: 10
- identifier: board - identifier: board
name: Board name: Board
url: /about/board/ url: /about/board/
params:
url_en: /en/about/board/
url_de: /de/ueber/vorstand/
weight: 20 weight: 20
- identifier: documents - identifier: documents
name: Dokuments name: Dokuments
url: /about/documents/ url: /about/documents/
weight: 30 params:
dropdown: url_en: /en/about/documents/
- identifier: foundation url_de: /de/ueber/dokumente/
pre: stars # can be stars, comments or piechart
name: Appearance
post: "Easy customization"
url: "#"
weight: 10
- identifier: comments
pre: comments # can be stars, comments or piechart
name: Comments
post: "Check your latest comments"
url: "#"
weight: 20
- identifier: analytics
pre: piechart # can be stars, comments or piechart
name: Analytics
post: "Take a look at your statistics"
url: "#"
weight: 30 weight: 30
footer: footer:
- identifier: about - identifier: about

View File

@ -1,11 +1,11 @@
{{- if eq .lang "en" -}} {{- if eq .lang "en" -}}
{{- with .menu.url_en -}} {{- with .menu.Params.url_en -}}
{{- relURL . -}} {{- relURL . -}}
{{- else -}} {{- else -}}
{{- .menu.URL | absLangURL -}} {{- .menu.URL | absLangURL -}}
{{- end -}} {{- end -}}
{{- else -}} {{- else -}}
{{- with .menu.url_de -}} {{- with .menu.Params.url_de -}}
{{- relURL . -}} {{- relURL . -}}
{{- else -}} {{- else -}}
{{- .menu.URL | absLangURL -}} {{- .menu.URL | absLangURL -}}

View File

@ -24,7 +24,7 @@
<nav :class="{'flex': open, 'hidden': !open}" <nav :class="{'flex': open, 'hidden': !open}"
class="flex-col flex-grow hidden pb-4 md:pb-0 md:flex md:justify-end md:flex-row"> class="flex-col flex-grow hidden pb-4 md:pb-0 md:flex md:justify-end md:flex-row">
{{ range site.Menus.main }} {{ range site.Menus.main }}
{{ $menuCtx := (dict "lang" $.Site.Language.Lang "menu" .Params) }} {{ $menuCtx := (dict "lang" $.Site.Language.Lang "menu" .) }}
{{ if (eq "complexdropdown" .Pre) }} {{ if (eq "complexdropdown" .Pre) }}
<div @click.away="open = false" class="relative" x-data="{ open: false }"> <div @click.away="open = false" class="relative" x-data="{ open: false }">
<button @click="open = !open" <button @click="open = !open"
@ -47,6 +47,7 @@
<div class="px-2 pt-2 pb-4 bg-white rounded-md shadow-lg text-zinc-900"> <div class="px-2 pt-2 pb-4 bg-white rounded-md shadow-lg text-zinc-900">
<div class="grid grid-cols-1 gap-4"> <div class="grid grid-cols-1 gap-4">
{{ range (index site.Menus .Identifier) }} {{ range (index site.Menus .Identifier) }}
{{ $menuCtx := (dict "lang" $.Site.Language.Lang "menu" .) }}
<a class="flex items-start p-2 bg-transparent rounded-lg group row hover:text-white focus:text-white hover:bg-primary-600 focus:bg-primary-700 focus:outline-none focus:shadow-outline" <a class="flex items-start p-2 bg-transparent rounded-lg group row hover:text-white focus:text-white hover:bg-primary-600 focus:bg-primary-700 focus:outline-none focus:shadow-outline"
href="{{ partial "menu-url.html" $menuCtx }}"> href="{{ partial "menu-url.html" $menuCtx }}">
<div class="p-3 text-white bg-primary-600 rounded-lg group-hover:bg-gray-900"> <div class="p-3 text-white bg-primary-600 rounded-lg group-hover:bg-gray-900">
@ -109,6 +110,7 @@
class="absolute right-0 z-30 w-full mt-2 origin-top-right rounded-md shadow-lg md:w-48"> class="absolute right-0 z-30 w-full mt-2 origin-top-right rounded-md shadow-lg md:w-48">
<div class="px-2 py-2 text-primary-900 bg-white rounded-md shadow"> <div class="px-2 py-2 text-primary-900 bg-white rounded-md shadow">
{{ range (index site.Menus .Identifier) }} {{ range (index site.Menus .Identifier) }}
{{ $menuCtx := (dict "lang" $.Site.Language.Lang "menu" .) }}
<a class="block px-4 py-2 mt-2 text-sm font-semibold bg-transparent rounded-lg md:mt-0 hover:text-white focus:text-white hover:bg-primary-600 focus:bg-primary-600 focus:outline-none focus:shadow-outline" <a class="block px-4 py-2 mt-2 text-sm font-semibold bg-transparent rounded-lg md:mt-0 hover:text-white focus:text-white hover:bg-primary-600 focus:bg-primary-600 focus:outline-none focus:shadow-outline"
href="{{ partial "menu-url.html" $menuCtx }}">{{- or (T .Identifier) .Name | safeHTML -}} href="{{ partial "menu-url.html" $menuCtx }}">{{- or (T .Identifier) .Name | safeHTML -}}
</a> </a>