fix: always fetch menu name from data file (#296)
This commit is contained in:
parent
5c22ce57dc
commit
2805fbd33a
3 changed files with 13 additions and 19 deletions
|
@ -1,9 +1,12 @@
|
||||||
---
|
---
|
||||||
main:
|
main:
|
||||||
- name: Level 1
|
- name:
|
||||||
ref: "/toc-tree/level-1"
|
en: Level 1 (EN)
|
||||||
|
de: Level 1 (DE)
|
||||||
sub:
|
sub:
|
||||||
- name: Level 1.1
|
- name:
|
||||||
|
en: Level 1.1 (EN)
|
||||||
|
de: Level 1.1 (DE)
|
||||||
ref: "/toc-tree/level-1/level-1-1"
|
ref: "/toc-tree/level-1/level-1-1"
|
||||||
- name: Level 1.2
|
- name: Level 1.2
|
||||||
ref: "/toc-tree/level-1/level-1-2"
|
ref: "/toc-tree/level-1/level-1-2"
|
||||||
|
|
|
@ -10,16 +10,16 @@
|
||||||
|
|
||||||
<ul class="gdoc-nav__list">
|
<ul class="gdoc-nav__list">
|
||||||
{{ range sort (default (seq 0) .sect) "weight" }}
|
{{ range sort (default (seq 0) .sect) "weight" }}
|
||||||
{{ $current.Scratch.Set "current" $current }}
|
{{ $name := .name }}
|
||||||
{{ $current.Scratch.Set "site" $site }}
|
{{ if reflect.IsMap .name }}
|
||||||
|
{{ $name = (index .name $site.Language.Lang) }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
{{ $ref := default false .ref }}
|
{{ $ref := default false .ref }}
|
||||||
{{ if $ref }}
|
{{ if $ref }}
|
||||||
{{ $site := $current.Scratch.Get "site" }}
|
|
||||||
{{ $this := $site.GetPage .ref }}
|
{{ $this := $site.GetPage .ref }}
|
||||||
{{ $current := $current.Scratch.Get "current" }}
|
|
||||||
{{ $icon := default false .icon }}
|
{{ $icon := default false .icon }}
|
||||||
{{ $numberOfPages := (add (len $this.Pages) (len $this.Sections)) }}
|
{{ $numberOfPages := (add (len $this.Pages) (len $this.Sections)) }}
|
||||||
{{ $isCurrent := eq $current $this }}
|
{{ $isCurrent := eq $current $this }}
|
||||||
|
@ -27,13 +27,6 @@
|
||||||
{{ $id := substr (sha1 $this.Permalink) 0 8 }}
|
{{ $id := substr (sha1 $this.Permalink) 0 8 }}
|
||||||
{{ $doCollapse := and (isset . "sub") (or $this.Params.GeekdocCollapseSection (default false .Site.Params.GeekdocCollapseAllSections)) }}
|
{{ $doCollapse := and (isset . "sub") (or $this.Params.GeekdocCollapseSection (default false .Site.Params.GeekdocCollapseAllSections)) }}
|
||||||
|
|
||||||
{{ if reflect.IsMap .name }}
|
|
||||||
{{ $current.Scratch.Set "refName" (index .name $site.Language.Lang) }}
|
|
||||||
{{ else }}
|
|
||||||
{{ $current.Scratch.Set "refName" .name }}
|
|
||||||
{{ end }}
|
|
||||||
{{ $name := $current.Scratch.Get "refName" }}
|
|
||||||
|
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
@ -80,7 +73,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with .sub }}
|
{{ with .sub }}
|
||||||
{{ template "menu-file" dict "sect" . "current" ($current.Scratch.Get "current") "site" ($current.Scratch.Get "site") }}
|
{{ template "menu-file" dict "sect" . "current" $current "site" $site }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -15,12 +15,10 @@
|
||||||
{{ $isCurrent := eq $current $this }}
|
{{ $isCurrent := eq $current $this }}
|
||||||
{{ $icon := default false .icon }}
|
{{ $icon := default false .icon }}
|
||||||
|
|
||||||
|
{{ $name := .name }}
|
||||||
{{ if reflect.IsMap .name }}
|
{{ if reflect.IsMap .name }}
|
||||||
{{ $current.Scratch.Set "refName" (index .name $site.Language.Lang) }}
|
{{ $name = (index .name $site.Language.Lang) }}
|
||||||
{{ else }}
|
|
||||||
{{ $current.Scratch.Set "refName" .name }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $name := $current.Scratch.Get "refName" }}
|
|
||||||
|
|
||||||
{{ if not .icon }}
|
{{ if not .icon }}
|
||||||
{{ errorf "Missing 'icon' attribute in data file for '%s' menu item '%s'" $target $name }}
|
{{ errorf "Missing 'icon' attribute in data file for '%s' menu item '%s'" $target $name }}
|
||||||
|
|
Loading…
Reference in a new issue