summaryrefslogtreecommitdiffstats
path: root/layouts/_default/list.json
blob: 5742bb3a0acd28360aef7321e72a228975a12e86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}

{{- $pages := slice -}}
{{- if $.IsHome -}}
    {{- $mainSections := site.Params.mainSections | default (slice "posts") }}
    {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}}
{{- else if $.IsSection -}}
    {{- $pages = $pctx.RegularPages.ByDate.Reverse -}}
{{- else -}}
    {{- $pages = $pctx.Pages -}}
{{- end -}}

{{- $.Scratch.Add "pagesIndex" slice -}}

{{- range $index, $page := $pages -}}
  {{- if gt (len $page.Content) 0 -}}
    {{- $pageData := (dict
      "title" $page.Title
      "href" $page.Permalink
      "tags" (delimit ($page.Params.tags | default slice) " ; ")
      "categories" (delimit ($page.Params.categories | default slice) " ; ")
      "content" $page.Plain
    ) -}}
    {{- $.Scratch.Add "pagesIndex" $pageData -}}
  {{- end -}}
{{- end -}}

{{- $.Scratch.Get "pagesIndex" | jsonify -}}