diff options
author | Steve Huff <shuff@vecna.org> | 2018-05-01 14:05:54 +0300 |
---|---|---|
committer | Steve Huff <shuff@vecna.org> | 2018-05-01 14:05:54 +0300 |
commit | 2c06c00351863122ba8c63fcca50f2ed022100c6 (patch) | |
tree | 415813bae2c792ea23cf8bb551ede610ac3c2bfd /layouts | |
parent | f305cd125db3e4fece61344cbdb6d0bcdec0a4cd (diff) |
fix: allow only one mainMenu item
Currently the theme errors if there is only one item in `.Site.Params.mainMenu`, as follows:
```
Building sites … ERROR 2018/05/01 18:27:08 Error while rendering "taxonomyTerm" in "": template: theme/_default/list.html:7:9: executing "theme/_default/list.html" at <after 1 .Site.Params...>: error calling after: no items left
```
This change wraps that `range` in a conditional to ensure that it won't
run if it would return zero lines.
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/list.html | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 6a14f0f..d00d90f 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -4,6 +4,8 @@ {{ .Date.Format (.Site.Params.dateForm | default "Mon Jan 02, 2006")}} -- {{ end }}<a href="{{.Permalink}}">{{.Title}}</a></li>{{ end }}</div>{{ if .Site.Params.mainMenu }}<div class="section bottom-menu"><hr/><p>{{ range first 1 .Site.Params.mainMenu }}<a href="{{ .link }}">{{ .text }}</a>{{ end }} +{{ if ( gt ( len .Site.Params.mainMenu ) 1 ) }} {{ range after 1 .Site.Params.mainMenu }} · <a href="{{ .link }}">{{ .text }}</a>{{ end }} -· <a href="{{.Site.BaseURL}}">{{ .Site.Params.homepage }}</a></p></div>{{ end }}<div class="section footer">{{ partial "footer.html" . }}</div></div></body>
\ No newline at end of file +{{ end }} +· <a href="{{.Site.BaseURL}}">{{ .Site.Params.homepage }}</a></p></div>{{ end }}<div class="section footer">{{ partial "footer.html" . }}</div></div></body> |