From 0031883094072237cf33587e3d069a5482008450 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 8 Oct 2023 21:56:13 +0200 Subject: [PATCH] Improved language chooser for translated URLs --- content/about/index.de.md | 1 + content/about/index.en.md | 2 ++ layouts/_default/about.html | 31 +++++++++++++++++++++++++++++++ layouts/partials/nav.html | 17 ++++++++++++++--- 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 layouts/_default/about.html diff --git a/content/about/index.de.md b/content/about/index.de.md index 9149b98..b445341 100644 --- a/content/about/index.de.md +++ b/content/about/index.de.md @@ -7,6 +7,7 @@ description: Kontaktinformationen für NewPipe e.V. people_heading: Vertretungsberechtigte Personen permalink: ueber url: /de/ueber +url_en: /en/about people_text: | Dies sind die Personen, die offiziell für das NewPipe-Projekt und den NewPipe e.V. Verein verantwortlich sind. Wenn du uns kontaktieren möchtest, nutze bitte das untenstehende Formular. --- diff --git a/content/about/index.en.md b/content/about/index.en.md index 3ef7f6c..542aab9 100644 --- a/content/about/index.en.md +++ b/content/about/index.en.md @@ -5,6 +5,8 @@ draft: false layout: about description: A test with @tailwindcss/typography & Prose people_heading: Representative persons +url: /en/about +url_de: /de/ueber people_text: | These are the people who are officially responsible for the NewPipe project and the NewPipe e.V. association. If you want to contact us, please use the form below. --- diff --git a/layouts/_default/about.html b/layouts/_default/about.html new file mode 100644 index 0000000..ac2e715 --- /dev/null +++ b/layouts/_default/about.html @@ -0,0 +1,31 @@ +{{define "main"}} +
+
+ +

+ {{ .Title }} +

+
+
+
+

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

+

{{ .Params.people_heading }}

+

{{ .Params.people_text }}

+
+ {{range .Site.Data.people }} +
+
+ +
+

{{ .name }}

+

{{ T .role }}

+

Lorem ipsum dolor sit amet consectetur, adipisicing elit.

+
+
+
+ {{end}} +
+ +
+
+{{end}} \ No newline at end of file diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index 3bc19e9..1ae7e3a 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -153,12 +153,23 @@ x-transition:leave-end="transform opacity-0 scale-95" class="absolute right-0 z-30 w-full mt-2 origin-top-right rounded-md shadow-lg md:w-48">
- {{$currentUrl := trim .Page.RelPermalink "/"}} + {{- $currentURL := trim .Page.RelPermalink "/" -}} {{ range (.Site.Languages) }} {{- .LanguageName -}} + {{- $url := "" -}} + {{- if eq .Lang $.Site.Language.Lang -}} + {{ $url = "." -}} + {{- else if isset $.Params "url_de" -}} + {{- $url = $.Params.url_de -}} + {{- else if isset $.Params "url_en" -}} + {{- $url = $.Params.url_en -}} + {{- else -}} + {{- $url = relURL (replace $currentURL $.Site.Language.Lang .Lang 1) -}} + {{- end }} + href="{{- $url | safeURL -}}"> + {{ .LanguageName }} - {{ end }} + {{- end }}