From 18ab2a17245f97f2ba7b0b477e79ff9afd7e51a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Fri, 12 Jul 2024 16:57:42 +0200 Subject: [PATCH] internal links with custom title --- layouts/shortcodes/internalLink.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/layouts/shortcodes/internalLink.html b/layouts/shortcodes/internalLink.html index 1045181..0c0891d 100644 --- a/layouts/shortcodes/internalLink.html +++ b/layouts/shortcodes/internalLink.html @@ -3,6 +3,7 @@ -- Currently, this shortcode can only handle Hugo sites with two languages. --> {{ $path := .Get "path" }} {{ $currentLang := .Page.Lang }} +{{ $title := .Get "title" }} {{ $sites := .Page.Sites }} {{ if ne $currentLang (index .Page.Sites 0).Language.Lang }} {{ $sites = collections.Reverse .Page.Sites }} @@ -10,7 +11,11 @@ {{ range $sites }} {{ with .GetPage $path }} +{{ if ne $title "" }} +{{ $title }} +{{ else }} {{ .Title }} +{{ end }} {{ if and (eq $currentLang "en") (eq .Lang "fr") }} {{- partial "icons/fr.svg" . -}}