Fix .File.UniqueID on zero object warning

This commit is contained in:
Helder Pereira 2020-02-11 23:33:18 +00:00 committed by Matthew Taylor
parent 41c6cc522f
commit f7847b6a3a

View file

@ -94,12 +94,14 @@
{{ define "section-tree-nav" }}
{{ $showvisitedlinks := .showvisitedlinks }}
{{ $currentNode := .currentnode }}
{{ $currentFileUniqueID := "" }}
{{ with $currentNode.File }}{{ $currentFileUniqueID = .UniqueID }}{{ end }}
{{with .sect}}
{{if and .IsSection ((not .Params.hidden) or $.showhidden)}}
{{safeHTML .Params.head}}
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item
{{if .IsAncestor $currentNode }}parent{{end}}
{{if eq .File.UniqueID $currentNode.File.UniqueID}}active{{end}}
{{if eq .File.UniqueID $currentFileUniqueID}}active{{end}}
{{if .Params.alwaysopen}}parent{{end}}
">
<a href="{{.RelPermalink}}">
@ -137,7 +139,7 @@
</li>
{{else}}
{{ if not .Params.Hidden }}
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item {{if eq .File.UniqueID $currentNode.File.UniqueID}}active{{end}}">
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item {{if eq .File.UniqueID $currentFileUniqueID}}active{{end}}">
<a href="{{ .RelPermalink}}">
{{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}}
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
@ -147,4 +149,3 @@
{{end}}
{{ end }}
{{ end }}