From 73e219f309127a387fdf7580ac2ef2aac03bd23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Fri, 12 Jul 2024 16:30:39 +0200 Subject: [PATCH] implement internal links --- layouts/shortcodes/internalLink.html | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/layouts/shortcodes/internalLink.html b/layouts/shortcodes/internalLink.html index 2d60bea..1045181 100644 --- a/layouts/shortcodes/internalLink.html +++ b/layouts/shortcodes/internalLink.html @@ -1,18 +1,26 @@ - + {{ $path := .Get "path" }} -{{ $lang := .Get "lang" }} {{ $currentLang := .Page.Lang }} -{{ range .Page.Sites }} -{{ if eq .Language.Lang $lang }} +{{ $sites := .Page.Sites }} +{{ if ne $currentLang (index .Page.Sites 0).Language.Lang }} +{{ $sites = collections.Reverse .Page.Sites }} +{{ end }} +{{ range $sites }} {{ with .GetPage $path }} {{ .Title }} -{{ if ne $currentLang $lang }} +{{ if and (eq $currentLang "en") (eq .Lang "fr") }} +{{- partial "icons/fr.svg" . -}} +{{ end }} +{{ if (eq $currentLang "fr") }} +{{- partial "lang-detection.html" . -}} +{{ if .Scratch.Get "en_article_in_fr_site" }} {{- partial "icons/en.svg" . -}} {{ end }} -{{ else }} -{{ errorf "shortcode internalLink: Cannot find page %q with lang %q" $path $lang }} {{ end }} +{{ break }} {{ end }} {{ end }}