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>
soper-book
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 # /!\ 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. # (Optional, experimental, default false) Enables service worker that caches visited pages and resources for offline use.
BookServiceWorker = true 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 # /!\ 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. # (Optional, experimental, default false) Enables service worker that caches visited pages and resources for offline use.
BookServiceWorker: true 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 --> <!-- Merge home and current page translations -->
{{ $bookTranslatedOnly := default false .Site.Params.BookTranslatedOnly }}
{{ $translations := dict }} {{ $translations := dict }}
{{ range .Site.Home.AllTranslations }} {{ if (eq $bookTranslatedOnly false ) }}
{{ $translations = merge $translations (dict .Language.Lang .) }} {{ range .Site.Home.AllTranslations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }}
{{ end }} {{ end }}
{{ range .Translations }} {{ range .Translations }}
{{ $translations = merge $translations (dict .Language.Lang .) }} {{ $translations = merge $translations (dict .Language.Lang .) }}