Use lang.Merge to "fill in the gaps" for untranslated pages

For example, to get pages under the About Hugo section to show up
on https://gohugo.io/zh/about/.

This commit is non-exhaustive; more work is necessary.

Also bump theme min_version to 0.38 due to the use of the new
lang.Merge function.
This commit is contained in:
Anthony Fok 2018-05-03 18:53:52 -06:00
parent ef079406cf
commit 56e4e95d9e
No known key found for this signature in database
GPG Key ID: EA2500B412C59ACF
5 changed files with 19 additions and 17 deletions

View File

@ -1,4 +1,5 @@
{{ define "main" }} {{ define "main" }}
{{ $section_to_display := .Sections | default .Paginator.Pages }} {{ $paginator := .Paginate (.Pages | lang.Merge (where .Sites.First.RegularPages "Section" .Section)) }}
{{ $section_to_display := .Sections | default $paginator.Pages }}
{{ partial "pagelayout.html" (dict "context" . "section_to_display" $section_to_display ) }} {{ partial "pagelayout.html" (dict "context" . "section_to_display" $section_to_display ) }}
{{ end }} {{ end }}

View File

@ -28,7 +28,8 @@
{{ $interior_classes := $.Site.Params.flex_box_interior_classes }} {{ $interior_classes := $.Site.Params.flex_box_interior_classes }}
<section class="flex-ns flex-wrap justify-between w-100 w-80-nsTK v-top"> <section class="flex-ns flex-wrap justify-between w-100 w-80-nsTK v-top">
{{ range .Paginator.Pages }} {{ $paginator := .Paginate (.Pages | lang.Merge (where .Sites.First.RegularPages "Section" .Section)) -}}
{{ range $paginator.Pages }}
{{ partial "boxes-section-summaries" (dict "context" . "classes" $interior_classes "fullcontent" false) }} {{ partial "boxes-section-summaries" (dict "context" . "classes" $interior_classes "fullcontent" false) }}
{{ end }} {{ end }}
</section> </section>

View File

@ -1,4 +1,4 @@
{{ define "main" }} {{ define "main" }}
{{ $section_to_display := (.Site.Taxonomies.categories.fundamentals).Pages }} {{ $section_to_display := (.Site.Taxonomies.categories.fundamentals).Pages | lang.Merge (.Sites.First.Taxonomies.categories.fundamentals).Pages }}
{{ partial "pagelayout.html" (dict "context" . "section_to_display" $section_to_display ) }} {{ partial "pagelayout.html" (dict "context" . "section_to_display" $section_to_display ) }}
{{ end }} {{ end }}

View File

@ -6,18 +6,18 @@
<li class="f5 w-100 hover-bg-light-gray hover-accent-color-light fw8{{ if eq $post "break" }} mb1 bb b--moon-gray{{ end }}"> <li class="f5 w-100 hover-bg-light-gray hover-accent-color-light fw8{{ if eq $post "break" }} mb1 bb b--moon-gray{{ end }}">
<a href="{{ if .HasChildren }}javascript:void(0){{ else }}{{ .URL }}{{ end }}" class="js-toggle dib w-100 link mid-gray hover-accent-color-light pl2 pr2 pv2 {{if or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) }} primary-color{{end}}" data-target=".{{ .Identifier }}">{{ .Name }}</a> <a href="{{ if .HasChildren }}javascript:void(0){{ else }}{{ .URL }}{{ end }}" class="js-toggle dib w-100 link mid-gray hover-accent-color-light pl2 pr2 pv2 {{if or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) }} primary-color{{end}}" data-target=".{{ .Identifier }}">{{ .Name }}</a>
{{ if .HasChildren }} {{- if .HasChildren }}
<ul class="{{ .Identifier }} desktopmenu animated fadeIn list pl0 bg-light-gray{{if $currentPage.HasMenuCurrent "docs" . }} db{{ else }} dn{{ end }}"> <ul class="{{ .Identifier }} desktopmenu animated fadeIn list pl0 bg-light-gray{{if $currentPage.HasMenuCurrent "docs" . }} db{{ else }} dn{{ end }}">
{{ range .Children }} {{- range .Children }}
<li class="f6 fw4"> <li class="f6 fw4">
<a href="{{.URL}}" class="db link hover-bg-gray hover-white pl3 pr2 pv2 {{if $currentPage.IsMenuCurrent "docs" . }}primary-color {{ else }}black {{end}}"> <a href="{{.URL}}" class="db link hover-bg-gray hover-white pl3 pr2 pv2 {{if $currentPage.IsMenuCurrent "docs" . }}primary-color {{ else }}black {{end}}">
{{ .Name }} {{ .Name }}
</a> </a>
</li> </li>
{{ end }} {{- end}}
</ul> </ul>
{{end}} {{- end}}
</li> </li>
{{end}} {{- end}}
</ul> </ul>
</nav> </nav>

View File

@ -8,7 +8,7 @@ description = ""
homepage = "https://github.com/budparr/gohugo.io" homepage = "https://github.com/budparr/gohugo.io"
tags = ["website"] tags = ["website"]
features = ["", ""] features = ["", ""]
min_version = 0.18 min_version = 0.38
[author] [author]
name = "Bud Parr" name = "Bud Parr"