Add pages-list shortcode
Produces a list of pages in a section.
This commit is contained in:
parent
aee96476a7
commit
b130db28e0
1 changed files with 33 additions and 0 deletions
33
layouts/shortcodes/pages-list.html
Normal file
33
layouts/shortcodes/pages-list.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
{{- $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 }}
|
Loading…
Add table
Add a link
Reference in a new issue