Browse Source

internal links with custom title

main
Nicolas Massé 1 year ago
parent
commit
18ab2a1724
  1. 5
      layouts/shortcodes/internalLink.html

5
layouts/shortcodes/internalLink.html

@ -3,6 +3,7 @@
-- Currently, this shortcode can only handle Hugo sites with two languages. --> -- Currently, this shortcode can only handle Hugo sites with two languages. -->
{{ $path := .Get "path" }} {{ $path := .Get "path" }}
{{ $currentLang := .Page.Lang }} {{ $currentLang := .Page.Lang }}
{{ $title := .Get "title" }}
{{ $sites := .Page.Sites }} {{ $sites := .Page.Sites }}
{{ if ne $currentLang (index .Page.Sites 0).Language.Lang }} {{ if ne $currentLang (index .Page.Sites 0).Language.Lang }}
{{ $sites = collections.Reverse .Page.Sites }} {{ $sites = collections.Reverse .Page.Sites }}
@ -10,7 +11,11 @@
{{ range $sites }} {{ range $sites }}
{{ with .GetPage $path }} {{ with .GetPage $path }}
<a href="{{ .RelPermalink }}"> <a href="{{ .RelPermalink }}">
{{ if ne $title "" }}
{{ $title }}
{{ else }}
{{ .Title }} {{ .Title }}
{{ end }}
</a> </a>
{{ if and (eq $currentLang "en") (eq .Lang "fr") }} {{ if and (eq $currentLang "en") (eq .Lang "fr") }}
{{- partial "icons/fr.svg" . -}} {{- partial "icons/fr.svg" . -}}

Loading…
Cancel
Save