Fix '.File.UniqueID on zero object' warning

This commit is contained in:
Ta-Ching Chen 2020-03-11 16:58:53 +08:00
parent 6a834ae6b8
commit 3439e019b0

View file

@ -80,8 +80,12 @@
{{ $currentNode := .currentnode }} {{ $currentNode := .currentnode }}
{{with .sect}} {{with .sect}}
{{safeHTML .Params.head}} {{safeHTML .Params.head}}
{{ $fileUniqueID := "" }}
{{ with .File }}{{ $fileUniqueID = .UniqueID }}{{ end }}
{{ $currentNodeFileUniqueID := "" }}
{{ with $currentNode.File }}{{ $currentNodeFileUniqueID = .UniqueID }}{{ end }}
<li data-nav-id="{{.Permalink}}" title="{{.Title}}" class="sidelist <li data-nav-id="{{.Permalink}}" title="{{.Title}}" class="sidelist
{{if eq .File.UniqueID $currentNode.File.UniqueID}}active{{end}}"> {{if eq $fileUniqueID $currentNodeFileUniqueID}}active{{end}}">
<a href="{{.Permalink}}"> <a href="{{.Permalink}}">
{{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}} {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}}
</a> </a>