Add OnlyTranslated property (#303)

* Add OnlyTranslated property

Signed-off-by: Alex Ivanov <ai@contributor.pw>

* Add newlines

Signed-off-by: Alex Ivanov <ai@contributor.pw>

* rename property

Signed-off-by: Alex Ivanov <ai@contributor.pw>
This commit is contained in:
Alex Ivanov 2021-01-21 13:42:26 +03:00 committed by GitHub
parent e53a638b2c
commit c828c6660f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -105,3 +105,7 @@ enableGitInfo = true
# /!\ This is an experimental feature, might be removed or changed at any time
# (Optional, experimental, default false) Enables service worker that caches visited pages and resources for offline use.
BookServiceWorker = true
# /!\ This is an experimental feature, might be removed or changed at any time
# (Optional, experimental, default false) Enables a drop-down menu for translations only if a translation is present.
BookTranslatedOnly = true

View file

@ -101,3 +101,7 @@ params:
# /!\ This is an experimental feature, might be removed or changed at any time
# (Optional, experimental, default false) Enables service worker that caches visited pages and resources for offline use.
BookServiceWorker: true
# /!\ This is an experimental feature, might be removed or changed at any time
# (Optional, experimental, default false) Enables a drop-down menu for translations only if a translation is present.
BookTranslatedOnly: true

View file

@ -1,7 +1,10 @@
<!-- Merge home and current page translations -->
{{ $bookTranslatedOnly := default false .Site.Params.BookTranslatedOnly }}
{{ $translations := dict }}
{{ range .Site.Home.AllTranslations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ if (eq $bookTranslatedOnly false ) }}
{{ range .Site.Home.AllTranslations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }}
{{ end }}
{{ range .Translations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}