{{- /* paginator.html (partial): Renders a paginated list of items as styled cards. Features: - Custom sorting: Pages with 'weight' are prioritized, then all pages are sorted by date (descending). Pagination is applied to this final sorted list. - "New" indicator: Displayed if the item was published within 7 days of the site build. - Metadata: Shows series (if any) and the first category (if any). - Decorative Accent: Displays the first letter of the item's title as a large, stylized background element. Dependency: `partial "pagination.html"` Condition for Display: - This partial is rendered if `paginate = true` is in the calling template's frontmatter, or if `paginate` is not defined (nil) in the current page's frontmatter. - To disable, explicitly set `paginate = false` in the page's frontmatter. Repo: https://github.com/oxypteros/alpha */ -}} {{- /* Enable this paginator if `paginate = true` in the frontmatter or the key is missing in page's that use the list layout. Must explicitly set to false to disable the pagination */}} {{- if or ( eq .Params.paginate true) (eq .Page.Params.paginate nil) }}
{{- /** Show first the weighted pages and after the unweighted */}} {{ $weightedPages := where .Pages "Weight" "gt" 0 }} {{ $unweightedPages := where .Pages "Weight" "eq" 0 }} {{ $sortedWeighted := sort $weightedPages "Weight" "asc" ".Date" "desc" }} {{ $sortedUnweighted := sort $unweightedPages ".Date" "desc" }} {{ $finalPages := $sortedWeighted }} {{ $finalPages = append $sortedUnweighted $finalPages }} {{ range (.Paginate $finalPages).Pages }} {{- /* Find the first letter of the title */}} {{- $titleAccent := substr .Title 0 1 }} {{- /* Display only the first category term of the taxonomy*/}} {{- $categories := .GetTerms "categories" }} {{- $category := "" }} {{- range first 1 $categories }} {{- $category = .LinkTitle }} {{- end }} {{- /* Display 'new' badge only if `date` < 7 days from last build */}} {{- $new := gt .Date (now.AddDate 0 0 -7) }}
{{- if $new }} {{- $date := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{- end }}

{{ .Title }}

{{- if or .Page.Params.series $categories }}
{{ with .Page.Params.series }} {{ . }} {{- end }}
{{- with $category }} {{ . }} {{- end }}
{{- else }} {{- /* Maintain the card layout if no series/category */}}
{{- end }}
{{- end }}
{{- partial "pagination.html" . }}
{{- end }}