Skip to content

Commit

Permalink
Fix .File.UniqueID on zero object warning (#41)
Browse files Browse the repository at this point in the history
Avoid warning message when hugo is building the site:

Building sites … WARN 2020/03/10 15:05:30 .File.UniqueID on zero object.
Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}

cherry picked from  matcornic/hugo-theme-learn#372

Co-authored-by: Flavio Fernandes <flaviof@redhat.com>
  • Loading branch information
flavio-fernandes and flavio-fernandes authored Mar 18, 2020
1 parent 4150a95 commit c761ff3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/themes/hugo-theme-learn/layouts/partials/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ <h3>{{ if not $disableShortcutsTitle}}{{ T "Shortcuts-Title"}}{{ end }}</h3>
{{ 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}}">
Expand Down Expand Up @@ -137,7 +139,7 @@ <h3>{{ if not $disableShortcutsTitle}}{{ T "Shortcuts-Title"}}{{ end }}</h3>
</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}}
Expand All @@ -147,4 +149,3 @@ <h3>{{ if not $disableShortcutsTitle}}{{ T "Shortcuts-Title"}}{{ end }}</h3>
{{end}}
{{ end }}
{{ end }}

0 comments on commit c761ff3

Please sign in to comment.