From f08ccf839e9da9d6b0fe87f6f518426655107729 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Thu, 5 Jan 2023 01:09:46 -0500 Subject: [PATCH] Reintroducing item factorization --- layouts/_default/item.json.json | 28 ++++++++++++++++++++++++++++ layouts/_default/list.json.json | 9 +-------- layouts/_default/single.json.json | 29 +---------------------------- 3 files changed, 30 insertions(+), 36 deletions(-) create mode 100644 layouts/_default/item.json.json diff --git a/layouts/_default/item.json.json b/layouts/_default/item.json.json new file mode 100644 index 0000000..f69b9e6 --- /dev/null +++ b/layouts/_default/item.json.json @@ -0,0 +1,28 @@ +{ + "id": "{{ .Permalink }}", + "url": "{{ .Permalink }}", + "title": {{ .Title | jsonify }}, + "authors": [ + {{with $.Site.Author.name }} + { "name": "{{ . }}" } + {{ end }} + ], + "content_html": {{ .Content | jsonify }}, + "date_published": "{{ .Date.Format "2006.01.02" }}", + "tags": {{ .Params.tags | jsonify }}, + "_syndication": { + "mastodon": { + "enabled": {{ .Params.mastodon_enabled | default "false" }}, + "toot_id": {{ .Params.mastodon_toot_id | default "null" }} + }, + "medium": { + "enabled": {{ .Params.medium_enabled | default "false" }}, + "post_id": {{ .Params.medium_post_id | default "null" }} + }, + "substack": { + "enabled": {{ .Params.substack_enabled | default "false" }}, + "post_id": {{ .Params.substack_post_id | default "null" }} + } + + } +} \ No newline at end of file diff --git a/layouts/_default/list.json.json b/layouts/_default/list.json.json index f59ff05..6f59b8e 100644 --- a/layouts/_default/list.json.json +++ b/layouts/_default/list.json.json @@ -13,14 +13,7 @@ ], "items": [ {{ range $index, $page := .Pages }}{{ if ne $index 0 }},{{ end }} - { - "id": "{{ $page.Permalink }}", - "url": "{{ $page.Permalink }}", - "title": {{ $page.Title | jsonify }}, - "content_html": {{ $page.Content | jsonify }}, - "date_published": "{{ $page.Date.Format "2006.01.02" }}", - "tags": {{ $page.Params.tags | jsonify }} - } + {{ .Render "item"}} {{ end }} ] } diff --git a/layouts/_default/single.json.json b/layouts/_default/single.json.json index f69b9e6..9811ca8 100644 --- a/layouts/_default/single.json.json +++ b/layouts/_default/single.json.json @@ -1,28 +1 @@ -{ - "id": "{{ .Permalink }}", - "url": "{{ .Permalink }}", - "title": {{ .Title | jsonify }}, - "authors": [ - {{with $.Site.Author.name }} - { "name": "{{ . }}" } - {{ end }} - ], - "content_html": {{ .Content | jsonify }}, - "date_published": "{{ .Date.Format "2006.01.02" }}", - "tags": {{ .Params.tags | jsonify }}, - "_syndication": { - "mastodon": { - "enabled": {{ .Params.mastodon_enabled | default "false" }}, - "toot_id": {{ .Params.mastodon_toot_id | default "null" }} - }, - "medium": { - "enabled": {{ .Params.medium_enabled | default "false" }}, - "post_id": {{ .Params.medium_post_id | default "null" }} - }, - "substack": { - "enabled": {{ .Params.substack_enabled | default "false" }}, - "post_id": {{ .Params.substack_post_id | default "null" }} - } - - } -} \ No newline at end of file +{{ .Render "item" }} \ No newline at end of file