Generalize translation menus
This commit is contained in:
parent
a8c0f3734f
commit
17caeb985f
@ -3,6 +3,7 @@ title: "Guia da sintaxe markdown"
|
||||
date: "2020-01-03"
|
||||
description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
|
||||
tags: ["markdown", "syntax"]
|
||||
slug: "sintaxe-markdown"
|
||||
---
|
||||
|
||||
For a quick cheatsheet, check out https://simplemde.com/markdown-guide.
|
||||
|
7
exampleSite/content/blog/not-translated.md
Normal file
7
exampleSite/content/blog/not-translated.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "This File Was Not Translated"
|
||||
date: "2023-02-03"
|
||||
description: "An untranslated file"
|
||||
---
|
||||
|
||||
Lorem ipsum.
|
@ -1,15 +1,23 @@
|
||||
{{ range .Site.Menus.main.ByWeight }}
|
||||
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a>
|
||||
<a href="{{ absLangURL .URL }}">{{ .Name }}</a>
|
||||
{{ end }}
|
||||
<a href='mailto:{{ .Site.Params.email }}?subject={{ i18n "email-subject" }}"{{ .Page.Title | default .Site.Title }}"'>Email</a>
|
||||
<a href='mailto:{{ .Site.Params.email }}?subject={{ i18n "email-subject" }}"{{ default .Site.Title .Page.Title }}"'>Email</a>
|
||||
<a href="/index.xml">RSS</a>
|
||||
{{ $pageLang := .Page.Lang }}
|
||||
{{ if .IsTranslated }}
|
||||
{{ range .Translations }}
|
||||
{{ if ne $pageLang .Lang }}
|
||||
<a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
|
||||
|
||||
<!-- Convert this page's translations into a dict -->
|
||||
{{ $translations := dict }}
|
||||
{{ range .Translations }}
|
||||
{{ $translations = merge $translations (dict .Language.Lang .) }}
|
||||
{{ end }}
|
||||
|
||||
<!-- Create a link to every translation -->
|
||||
{{ range where .Site.Languages "Lang" "!=" .Page.Lang }}
|
||||
{{ with (index $translations .Lang) }}
|
||||
<a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
|
||||
{{ else }}
|
||||
<!-- The complicated setup was necessary to make a grayed out link -->
|
||||
{{ if not .Params.hideUntranslated }}
|
||||
<a class="disabled" href="">{{ .LanguageName }}</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else if not .Site.Params.hideUntranslated }}
|
||||
<a class="disabled" href="">{{ .Language.LanguageName }}</a>
|
||||
{{ end }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user