From b33454a0013f9eb3b35b011a7c155723c93e7728 Mon Sep 17 00:00:00 2001 From: Flavio Fernandes Date: Tue, 17 Mar 2020 10:56:24 -0400 Subject: [PATCH] Fix .File.UniqueID on zero object warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 https://github.com/matcornic/hugo-theme-learn/pull/372/ --- src/themes/hugo-theme-learn/layouts/partials/menu.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/themes/hugo-theme-learn/layouts/partials/menu.html b/src/themes/hugo-theme-learn/layouts/partials/menu.html index a6be42fa6..0f9c8f8a5 100644 --- a/src/themes/hugo-theme-learn/layouts/partials/menu.html +++ b/src/themes/hugo-theme-learn/layouts/partials/menu.html @@ -94,12 +94,14 @@

{{ if not $disableShortcutsTitle}}{{ T "Shortcuts-Title"}}{{ end }}

{{ 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}}
  • @@ -137,7 +139,7 @@

    {{ if not $disableShortcutsTitle}}{{ T "Shortcuts-Title"}}{{ end }}

  • {{else}} {{ if not .Params.Hidden }} -
  • +
  • {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}} {{ if $showvisitedlinks}}{{end}} @@ -147,4 +149,3 @@

    {{ if not $disableShortcutsTitle}}{{ T "Shortcuts-Title"}}{{ end }}

    {{end}} {{ end }} {{ end }} -