From 41f4e8c62b7b896f59792f759c136d2f616b86fd Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Wed, 8 Mar 2023 11:19:55 +0100 Subject: [PATCH 1/3] Avoid warning 'calling IsSet with unsupported type "invalid" ()' --- layouts/partials/sidebar-tree.html | 17 +++++++++++++---- layouts/partials/sidebar.html | 12 +++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/layouts/partials/sidebar-tree.html b/layouts/partials/sidebar-tree.html index eca2ab80a9..7f02010082 100644 --- a/layouts/partials/sidebar-tree.html +++ b/layouts/partials/sidebar-tree.html @@ -1,5 +1,8 @@ -{{/* We cache this partial for bigger sites and set the active class client side. */}} -{{ $sidebarCacheLimit := cond (isset .Site.Params.ui "sidebar_cache_limit") .Site.Params.ui.sidebar_cache_limit 2000 -}} +{{/* We cache this partial for bigger sites and set the active class client side. */ -}} +{{ $sidebarCacheLimit := 2000 -}} +{{ with .Site.Params.ui.sidebar_cache_limit -}} + {{ $sidebarCacheLimit = . -}} +{{ end -}} {{ $shouldDelayActive := ge (len .Site.Pages) $sidebarCacheLimit -}}
{{ if not .Site.Params.ui.sidebar_search_disable -}} @@ -26,8 +29,14 @@ {{ end -}} {{ $navRoot := cond (and (ne .Params.toc_root true) (eq .Site.Home.Type "docs")) .Site.Home .FirstSection -}} {{ $ulNr := 0 -}} - {{ $ulShow := cond (isset .Site.Params.ui "ul_show") .Site.Params.ui.ul_show 1 -}} - {{ $sidebarMenuTruncate := cond (isset .Site.Params.ui "sidebar_menu_truncate") .Site.Params.ui.sidebar_menu_truncate 50 -}} + {{ $ulShow := 1 -}} + {{ with .Site.Params.ui.ul_show -}} + {{ $ulShow = . -}} + {{ end -}} + {{ $sidebarMenuTruncate := 50 -}} + {{ with .Site.Params.ui.sidebar_menu_truncate -}} + {{ $sidebarMenuTruncate = . -}} + {{ end -}}
    {{ template "section-tree-nav-section" (dict "page" . "section" $navRoot "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" (add $ulShow 1)) }}
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 8d3fc5ae7b..2e4a268c44 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -1,7 +1,13 @@ -{{/* The "active" toggle here may delay rendering, so we only cache this side bar menu for bigger sites. -*/}}{{ $sidebarCacheLimit := cond (isset .Site.Params.ui "sidebar_cache_limit") .Site.Params.ui.sidebar_cache_limit 2000 -}} +{{/* The "active" toggle here may delay rendering, so we only cache this side bar menu for bigger sites. */ -}} +{{ $sidebarCacheLimit := 2000 -}} +{{ with .Site.Params.ui.sidebar_cache_limit -}} + {{ $sidebarCacheLimit = . -}} +{{ end -}} {{ $shouldCache := ge (len .Site.Pages) $sidebarCacheLimit -}} -{{ $sidebarCacheTypeRoot := cond (isset .Site.Params.ui "sidebar_cache_type_root") .Site.Params.ui.sidebar_cache_type_root false -}} +{{ $sidebarCacheTypeRoot := false -}} +{{ with .Site.Params.ui.sidebar_cache_type_root -}} + {{ $sidebarCacheTypeRoot = . -}} +{{ end -}} {{ if $shouldCache -}} {{ $mid := printf "m-%s" (.RelPermalink | anchorize) }}