hugo-theme-termlite/layouts/partials/page/first_section.list.html
Eryn Wells c4821daa6e Add a should_render.html partial
Encapsulates the decision making about whether a page should be rendered.
2024-11-13 17:03:17 -08:00

45 lines
1.4 KiB
HTML

{{- $page := .page -}}
{{- $class := .class | default "" -}}
<main class="main--list{{ with $class }} {{ . }}{{ end }}">
<header class="page-header">
{{ partial "page_header.html" (dict "page" $page) }}
</header>
{{/* Each page is a year section. */}}
{{- $yearPages := $page.Pages.ByPublishDate.Reverse -}}
{{- $yearLimit := math.Max ($.Site.Params.blog.yearLimit | default 5) 3 -}}
{{- $expandedYears := first $yearLimit $yearPages -}}
{{- $collapsedYears := after $yearLimit $yearPages -}}
{{-
partial "page/section_year_nav.html"
(dict
"years" $expandedYears
"includeCollapsedYearItem" (gt (len $collapsedYears) 0)
)
-}}
{{- $page.Content -}}
{{ range $expandedYears -}}
<section id="{{ .Date | time.Format "2006" }}" class="main__posts-by-year">
<h2 class="main__section-heading">{{ .Title }}</h2>
{{ range .RegularPagesRecursive.ByPublishDate.Reverse -}}
{{ if partial "page/should_render.html" . -}}
{{ .Render "page_summary" }}
{{ end }}
{{ end }}
</section>
{{- end }}
{{ with $collapsedYears -}}
<section id="older">
<h2 class="main__section-heading">{{ i18n "olderPagesSectionTitle" }}</h2>
<ul>
{{ range . -}}
<li><a href="{{ .Permalink }}">{{ .LinkTitle | markdownify }}</a></li>
{{ end }}
</ul>
</section>
{{ end }}
</main>