Collapse years past a certain number (defined in site config as photostream.yearLimit)

This commit is contained in:
Eryn Wells 2024-10-23 11:16:49 -07:00
parent a74703beb5
commit 4cb92ab5a9

View file

@ -4,17 +4,40 @@
{{ partial "page_header.html" (dict "page" .) }}
</header>
{{/* Each page is a year section. */}}
{{- $yearPages := .Pages.ByPublishDate.Reverse -}}
{{- $yearLimit := math.Max ($.Site.Params.blog.yearLimit | default 5) 1 -}}
{{- $expandedYears := first $yearLimit $yearPages -}}
{{- $collapsedYears := after $yearLimit $yearPages -}}
{{-
partial "page/section_year_nav.html"
(dict
"years" $expandedYears
"includeCollapsedYearItem" (gt (len $collapsedYears) 0)
)
-}}
{{- .Content -}}
{{ range .Pages.ByDate.Reverse.GroupByDate "2006" }}
{{ range $expandedYears }}
<section class="photostream-grid">
<header class="photostream-grid__date-heading">
<h2>{{ .Key }}</h2>
<header id="{{ .Date | time.Format "2006" }}" class="photostream-grid__date-heading">
<h2><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></h2>
</header>
{{ range .Pages }}
{{ range .RegularPagesRecursive.ByPublishDate.Reverse -}}
{{ .Render "page_summary" }}
{{ end }}
</section>
{{ end }}
{{ with $collapsedYears -}}
<h2 id="older">{{ i18n "olderPagesSectionTitle" }}</h2>
<ul>
{{ range . -}}
<li><a href="{{ .Permalink }}">{{ .LinkTitle | markdownify }}</a></li>
{{ end }}
</ul>
{{ end }}
</main>
{{ end }}