You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.1 KiB
26 lines
1.1 KiB
{{- /*
|
|
-- This shortcode generates the HTML link to an internal resource, which can be translated or not.
|
|
-- It displays a country flag when the target page is in a different language than the current page.
|
|
-- Currently, this shortcode can only handle Hugo sites with two languages.
|
|
--
|
|
-- The output must not contain any extra whitespace since the link is
|
|
-- usually embedded in a sentence.
|
|
*/ -}}
|
|
{{- $path := .Get "path" -}}
|
|
{{- $currentLang := .Page.Lang -}}
|
|
{{- $title := .Get "title" -}}
|
|
{{- $sites := hugo.Sites -}}
|
|
{{- if ne $currentLang (index hugo.Sites 0).Language.Lang -}}
|
|
{{- $sites = collections.Reverse hugo.Sites -}}
|
|
{{- end -}}
|
|
{{- range $sites -}}
|
|
{{- with .GetPage $path -}}
|
|
<a href="{{ .RelPermalink }}">{{ or $title .Title }}</a>
|
|
{{- if and (eq $currentLang "en") (eq .Lang "fr") }} {{ partial "icons/fr.svg" . | strings.TrimSpace | safeHTML }}{{ end -}}
|
|
{{- if eq $currentLang "fr" -}}
|
|
{{- partial "lang-detection.html" . -}}
|
|
{{- if .Store.Get "en_article_in_fr_site" }} {{ partial "icons/en.svg" . | strings.TrimSpace | safeHTML }}{{ end -}}
|
|
{{- end -}}
|
|
{{- break -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|