json feeds and favicon support master
authorkengrimes <ken@kengrimes.com>
Sat, 21 Apr 2018 23:21:08 +0000 (16:21 -0700)
committerkengrimes <ken@kengrimes.com>
Sat, 21 Apr 2018 23:21:08 +0000 (16:21 -0700)
layouts/_default/baseof.html
layouts/_default/list.json [new file with mode: 0644]
layouts/_default/single.json [new file with mode: 0644]
layouts/partials/meta.html [new file with mode: 0644]

index ddfb8b0..d57f909 100644 (file)
@@ -6,6 +6,7 @@
     <script src="/js/speedy.js"></script>
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
+    {{- partialCached "meta.html" . -}}
     {{ .Hugo.Generator }}
   </head>
   <body>
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 }}
+  ]
+}
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 }}
+    }
+  ]
+}
diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html
new file mode 100644 (file)
index 0000000..9a1b702
--- /dev/null
@@ -0,0 +1,13 @@
+{{ $iconRoot := cond (not $.Params.iconroot) "" $.Params.iconroot }}
+    <link rel="apple-touch-icon-precomposed" sizes="57x57" href="{{ printf `%s/apple-touch-icon-57x57.png` $iconRoot }}" />
+    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="{{ printf `%s/apple-touch-icon-114x114.png` $iconRoot }}" />
+    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="{{ printf `%s/apple-touch-icon-72x72.png` $iconRoot }}" />
+    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ printf `%s/apple-touch-icon-144x144.png` $iconRoot }}" />
+    <link rel="apple-touch-icon-precomposed" sizes="120x120" href="{{ printf `%s/apple-touch-icon-120x120.png` $iconRoot }}" />
+    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="{{ printf `%s/apple-touch-icon-152x152.png` $iconRoot }}" />
+    <link rel="icon" type="image/png" href="{{ printf `%s/favicon-32x32.png` $iconRoot }}" sizes="32x32" />
+    <link rel="icon" type="image/png" href="{{ printf `%s/favicon-16x16.png` $iconRoot }}" sizes="16x16" />
+    <meta name="application-name" content="Computers are the Devil"/>
+    <meta name="msapplication-TileColor" content="#FFFFFF" />
+    <meta name="msapplication-TileImage" content="{{ printf `%s/mstile-144x144.png` $iconRoot }}" />
+    <meta name="msapplication-notification" content="frequency=30;polling-uri=https://notifications.buildmypinnedsite.com/?feed={{ absURL (printf `%s/feed.xml`) }}&amp;id=1;polling-uri2=https://notifications.buildmypinnedsite.com/?feed={{ absURL (printf `%s/feed.xml`) }}&amp;id=2;polling-uri3=https://notifications.buildmypinnedsite.com/?feed={{ absURL (printf `%s/feed.xml`) }}&amp;id=3;polling-uri4=https://notifications.buildmypinnedsite.com/?feed={{ absURL (printf `%s/feed.xml`) }}&amp;id=4;polling-uri5=https://notifications.buildmypinnedsite.com/?feed={{ absURL (printf `%s/feed.xml`) }}&amp;id=5;cycle=1" />