diff --git a/layouts/partials/blog-sidebar-tree.html b/layouts/partials/blog-sidebar-tree.html new file mode 100644 index 0000000000..2755cc56fc --- /dev/null +++ b/layouts/partials/blog-sidebar-tree.html @@ -0,0 +1,89 @@ +{{/* The blog nav organizes posts grouped by year, which represents a customized version of the +sidebar-tree in use elsewhere on the site. */}} + +{{/* 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 -}} +{{ $shouldDelayActive := ge (len .Site.Pages) $sidebarCacheLimit -}} +
+ {{ if not .Site.Params.ui.sidebar_search_disable -}} + + {{ else -}} +
+ +
+
+ {{ end -}} + +
+{{ define "blog-section-tree-nav-section" -}} +{{ $s := .section -}} +{{ $p := .page -}} +{{ $shouldDelayActive := .shouldDelayActive -}} +{{ $sidebarMenuTruncate := .sidebarMenuTruncate -}} +{{ $ulNr := .ulNr -}} +{{ $ulShow := .ulShow -}} +{{ $postsByYear := $s.Pages.GroupByDate "2006" }} +{{ $active := and (not $shouldDelayActive) (eq $s $p) -}} +{{ $activePath := and (not $shouldDelayActive) (or (eq $p $s) ($p.IsDescendant $s)) -}} +{{ $show := cond (or (lt $ulNr $ulShow) $activePath (and (not $shouldDelayActive) (eq $s.Parent $p.Parent)) (and (not $shouldDelayActive) (eq $s.Parent $p)) (not $p.Site.Params.ui.sidebar_menu_compact) (and (not $shouldDelayActive) ($p.IsDescendant $s.Parent))) true false -}} +{{ $mid := printf "m-%s" ($s.RelPermalink | anchorize) -}} +
  • + {{- $ulNr := 1 }} + +
  • +{{- end }} diff --git a/layouts/partials/blog-sidebar.html b/layouts/partials/blog-sidebar.html index e769eca1e0..578a1ff465 100644 --- a/layouts/partials/blog-sidebar.html +++ b/layouts/partials/blog-sidebar.html @@ -1,99 +1,23 @@ -{{/* The blog nav organizes posts grouped by year, which represents a customized version of the -sidebar-tree in use elsewhere on the site. */}} - -{{/* We cache this partial for bigger sites and set the active class client side. */}} -{{ $shouldDelayActive := ge (len .Site.Pages) 2000 }} - -
    - - - - -
    - -{{ define "blog-nav-section" }} - -{{ $shouldDelayActive := .delayActive }} -{{ $sid := .section.RelPermalink | anchorize }} -{{ $postsByYear := .section.Pages.GroupByDate "2006" }} - - {{ range $postsByYear }} - - {{ $year := .Key }} - {{ $p := $.page }} - {{ $active := eq ($p.Date.Format "2006") $year }} - - {{ $firstPost := .Pages | first 1 }} - - - {{ end }} - -{{ end }} - -{{/* Reveal the remaining blog posts and hide the clicked link */}} - \ No newline at end of file +{{/* 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 -}} +{{ $shouldCache := ge (len .Site.Pages) $sidebarCacheLimit -}} +{{ $sidebarCacheTypeRoot := cond (isset .Site.Params.ui "sidebar_cache_type_root") .Site.Params.ui.sidebar_cache_type_root false -}} +{{ if $shouldCache -}} + {{ $mid := printf "m-%s" (.RelPermalink | anchorize) }} + + {{ partialCached "blog-sidebar-tree.html" . .FirstSection.RelPermalink }} +{{ else -}} + {{ partial "blog-sidebar-tree.html" . }} +{{- end }} \ No newline at end of file