json feeds and favicon support
[kengrimes.com/theme.git] / layouts / _default / single.json
diff --git a/layouts/_default/single.json b/layouts/_default/single.json
new file mode 100644 (file)
index 0000000..f4f1c34
--- /dev/null
@@ -0,0 +1,41 @@
+{{ $iconRoot := cond (not $.Params.iconroot) "" $.Params.iconroot }}
+{{- $sp := .Site.GetPage "section" .Section }}
+{{- $sh := cond (or (not $sp.Params.header) (not (fileExists (printf "static/%s" $sp.Params.header)))) (cond (or (not .Site.Home.Params.header) (not (fileExists (printf "static/%s" .Site.Home.Params.header)))) "/img/speedy.png" .Site.Home.Params.header) $sp.Params.header }}
+{{- $ph := cond (or (not .Params.header) (not (fileExists (printf "static/%s" .Params.header)))) $sh .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 $ph }}",
+  "favicon" : "{{ printf `%s%s/favicon-32x32.png` .Site.BaseURL $iconRoot }}",
+  {{- with .Site.Author }}
+  "author" : {
+    "name" : "{{ .name }}",
+    "url" : "{{ .url }}",
+    "avatar" : "{{ .avatar }}"
+  },
+  {{- end }}
+  "items" : [
+    {
+      "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 }}
+    }
+  ]
+}