mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2023-12-21 10:22:58 +01:00
feat: new language switch behaviour, always listing all languages by weight but linking to translations if available
feat: if language switch shows language codes (instead of full language name), those codes are now uppercase feat: translation list in post headers are replaced by links to translations in page headers - the old translation list in the post header can still be enabled using the boolean parameter "showTranslationListInPosts" (i.e. to turn it back on, add the parameter to your hugo.toml and set it to true)
This commit is contained in:
parent
25e5b4d298
commit
a0016f50f6
@ -36,7 +36,7 @@
|
|||||||
- Social Icons (home-info and profile-mode)
|
- Social Icons (home-info and profile-mode)
|
||||||
- Social-Media Share buttons on posts.
|
- Social-Media Share buttons on posts.
|
||||||
- Menu location indicator.
|
- Menu location indicator.
|
||||||
- Multilingual support. (with language selector)
|
- Multilingual support (with improved language selector)
|
||||||
- Taxonomies
|
- Taxonomies
|
||||||
- Cover image for each post (with Responsive image support).
|
- Cover image for each post (with Responsive image support).
|
||||||
- Light/Dark theme (automatic theme switch a/c to browser theme and theme-switch button).
|
- Light/Dark theme (automatic theme switch a/c to browser theme and theme-switch button).
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
{{ .Description }}
|
{{ .Description }}
|
||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if not (.Param "hideMeta") }}
|
{{- if and (.Param "showTranslationListInPosts") (not (.Param "hideMeta")) }}
|
||||||
<div class="post-meta">
|
<div class="post-meta">
|
||||||
{{- partial "translation_list.html" . -}}
|
{{- partial "translation_list.html" . -}}
|
||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
{{- if not (.Param "hideMeta") }}
|
{{- if not (.Param "hideMeta") }}
|
||||||
<div class="post-meta">
|
<div class="post-meta">
|
||||||
{{- partial "post_meta.html" . -}}
|
{{- partial "post_meta.html" . -}}
|
||||||
{{- partial "translation_list.html" . -}}
|
{{- if .Param "showTranslationListInPosts" }}
|
||||||
|
{{- partial "translation_list.html" . -}}
|
||||||
|
{{- end }}
|
||||||
{{- partial "edit_post.html" . -}}
|
{{- partial "edit_post.html" . -}}
|
||||||
{{- partial "post_canonical.html" . -}}
|
{{- partial "post_canonical.html" . -}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -96,27 +96,42 @@
|
|||||||
</button>
|
</button>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- $lang := .Lang}}
|
{{/* LANGUAGE SELECTOR */}}
|
||||||
{{- $separator := or $label_text (not site.Params.disableThemeToggle)}}
|
{{ if .Site.IsMultiLingual }}
|
||||||
{{- with site.Home.AllTranslations }}
|
{{/* set vars with page data */}}
|
||||||
<ul class="lang-switch">
|
{{ $currentLang := .Lang }}
|
||||||
{{- if $separator }}<li>|</li>{{ end }}
|
{{ $allTranslations := .Translations }}
|
||||||
{{- range . -}}
|
|
||||||
{{- if ne $lang .Lang }}
|
{{ $separator := or $label_text (not site.Params.disableThemeToggle)}}
|
||||||
<li>
|
|
||||||
<a href="{{- .Permalink -}}" title="{{ .Language.Params.languageAltTitle | default (.Language.LanguageName | emojify) | default (.Lang | title) }}"
|
<ul class="lang-switch">
|
||||||
aria-label="{{ .Language.LanguageName | default (.Lang | title) }}">
|
{{ if $separator }}<li>|</li>{{ end }}
|
||||||
{{- if (and site.Params.displayFullLangName (.Language.LanguageName)) }}
|
{{ range $anySiteLang := .Site.Home.AllTranslations }}
|
||||||
{{- .Language.LanguageName | emojify -}}
|
|
||||||
{{- else }}
|
{{/* code here can only access page-related data via vars set above */}}
|
||||||
{{- .Lang | title -}}
|
{{ if ne $currentLang $anySiteLang.Lang }}
|
||||||
{{- end -}}
|
{{ $translationLink := .Permalink }}
|
||||||
</a>
|
{{ range $translation := $allTranslations }}
|
||||||
</li>
|
{{ if eq $anySiteLang.Lang $translation.Lang }}
|
||||||
{{- end -}}
|
{{ $translationLink = $translation.Permalink }}
|
||||||
{{- end}}
|
{{ end }}
|
||||||
</ul>
|
{{ end }}
|
||||||
{{- end }}
|
|
||||||
|
<li>
|
||||||
|
<a href="{{ $translationLink }}"
|
||||||
|
title="{{ .Language.Params.languageAltTitle | default (.Language.LanguageName ) | default (.Lang | upper) }}"
|
||||||
|
aria-label="{{ .Language.LanguageName | default (.Lang | upper) }}">
|
||||||
|
{{ if site.Params.DisplayFullLangName }}
|
||||||
|
{{ .Language.LanguageName }}
|
||||||
|
{{ else }}
|
||||||
|
{{ .Lang | upper }}
|
||||||
|
{{ end }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{- $currentPage := . }}
|
{{- $currentPage := . }}
|
||||||
|
Loading…
Reference in New Issue
Block a user