Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matcornic/hugo-theme-learn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelder Pereira <helfper@gmail.com>2020-02-12 02:33:18 +0300
committerMatthew Taylor <matalo33@users.noreply.github.com>2020-03-09 18:25:50 +0300
commitf7847b6a3abc6dd2f67839c80a1144200768dd68 (patch)
tree32482c511910098823fe19ce30d0fcdbe54ea437
parent41c6cc522f13ac324e99e8bf84f2b67d88510ceb (diff)
Fix .File.UniqueID on zero object warning
-rw-r--r--layouts/partials/menu.html7
1 files changed, 4 insertions, 3 deletions
diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html
index a6be42f..0f9c8f8 100644
--- a/layouts/partials/menu.html
+++ b/layouts/partials/menu.html
@@ -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 }}
-