summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--exampleSite/config.toml8
-rw-r--r--layouts/_default/list.json29
-rw-r--r--layouts/_default/list.jsonfeed.json (renamed from layouts/_default/list.json.json)0
3 files changed, 33 insertions, 4 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 0660260..319e680 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -35,8 +35,8 @@ googleAnalytics = ''
disableXML = true
[outputs]
- home = [ 'HTML', 'Atom', 'FEED', 'JSON', 'MANIFEST', 'humanstxt' ]
- section = [ 'HTML', 'Atom', 'FEED', 'JSON' ]
+ home = [ 'HTML', 'Atom', 'FEED', 'JSONFEED', 'JSON', 'MANIFEST', 'humanstxt' ]
+ section = [ 'HTML', 'Atom', 'FEED', 'JSONFEED' ]
page = [ 'HTML' ]
taxonomy = [ 'HTML' ]
term = [ 'HTML' ]
@@ -73,8 +73,8 @@ googleAnalytics = ''
permalinkable = false
# For more see: https://www.jsonfeed.org/
-[outputFormats.JSON]
- name = 'Json'
+[outputFormats.JSONFEED]
+ name = 'JsonFeed'
mediaType = 'application/feed+json'
baseName = 'feeds/feed'
rel = 'alternate'
diff --git a/layouts/_default/list.json b/layouts/_default/list.json
new file mode 100644
index 0000000..5742bb3
--- /dev/null
+++ b/layouts/_default/list.json
@@ -0,0 +1,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 -}}
diff --git a/layouts/_default/list.json.json b/layouts/_default/list.jsonfeed.json
index f6b89cc..f6b89cc 100644
--- a/layouts/_default/list.json.json
+++ b/layouts/_default/list.jsonfeed.json