json feeds and favicon support
[kengrimes.com/theme.git] / layouts / _default / list.json
diff --git a/layouts/_default/list.json b/layouts/_default/list.json
new file mode 100644 (file)
index 0000000..e869d70
--- /dev/null
@@ -0,0 +1,46 @@
+{{ $iconRoot := cond (not $.Params.iconroot) "" $.Params.iconroot }}
+{{- $sp := .Site.GetPage "section" .Section }}
+{{ $secIcon := cond (or (not $sp.Params.header) (not (fileExists (printf "static/%s" $sp.Params.header)))) "/img/speedy.png" $sp.Params.header }}
+{
+  "version" : "https://jsonfeed.org/version/1",
+  "title" : "{{ .Site.Title }} :: {{ .Title }}",
+  "description" : "{{ if not .Description }}{{ .Title }}{{ else }}{{ .Description }}{{ end }}",
+  "home_page_url": "{{ .Site.BaseURL }}",
+  "feed_url": "{{ .Site.BaseURL }}/index.json",
+  "icon" : "{{ printf `%s%s` .Site.BaseURL $secIcon }}",
+  "favicon" : "{{ printf `%s%s/favicon-32x32.png` .Site.BaseURL $iconRoot }}",
+  {{- with .Site.Author }}
+  "author" : {
+    "name" : "{{ .name }}",
+    "url" : "{{ .url }}",
+    "avatar" : "{{ .avatar }}"
+  },
+  {{- end }}
+  "items" : [
+    {{- $pages := .Pages.ByPublishDate.Reverse }}
+    {{- $length := (len $pages) }}
+    {{- range $index, $element := $pages }}
+    {{- $ph := cond (or (not .Params.header) (not (fileExists (printf "static/%s" .Params.header)))) (cond (or (not .Parent.Params.header) (not (fileExists (printf "static/%s" .Parent.Params.header))))  "/img/speedy.png" .Parent.Params.header) .Params.header }}
+    {
+      "title" : {{ jsonify .Title }},
+      "date_published" : "{{ .Date }}",
+      {{- if not .Lastmod }}
+      "date_modified" : "{{ .Date }}",
+      {{- else }}
+      "date_modified" : "{{ .Lastmod }}",
+      {{- end }}
+      "id" : "{{ .Permalink }}",
+      "url" : "{{ .Permalink }}",
+      {{- with .Params.author }}
+      "author" : {
+        "name" : "{{ . }}"
+      },
+      {{- end }}
+      "content_html" : {{ jsonify .Content }},
+      "summary" : {{ jsonify .Summary }},
+      "tags" : {{ jsonify .Params.tags }}
+    }{{ if ne (add $index 1) $length }},
+    {{ end }}
+    {{- end }}
+  ]
+}