hugo-theme-termlite/layouts/shortcodes/pages-list.html
Eryn Wells b130db28e0 Add pages-list shortcode
Produces a list of pages in a section.
2024-07-23 09:13:47 -07:00

33 lines
815 B
HTML

{{- $sectionName := .Get "section" -}}
{{- $limit := .Get "limit" -}}
{{- $style := .Get "style" | default "bullets" -}}
{{- $pagesSource := dict -}}
{{- with $sectionName -}}
{{ with $section := site.GetPage . }}
{{ $pagesSource = $section }}
{{ else }}
{{ errorf "Couldn't get Page for section named '%s'" . }}
{{ end }}
{{ else }}
{{ $pagesSource = site }}
{{- end -}}
{{- $pages := $pagesSource.Pages.ByTitle -}}
{{- with $limit -}}
{{ $pages = $pages.Limit $limit }}
{{- end -}}
{{ with $pages -}}
{{- if eq $style "bullets" }}
<ul>
{{ range $pages -}}
<li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ else if eq $style "summaries" }}
{{ range $pages }}
{{ .Render "page_summary" }}
{{ end }}
{{ end -}}
{{ end }}