Skip to content

Instantly share code, notes, and snippets.

@rys
Last active June 5, 2022 15:14
Show Gist options
  • Save rys/b6009b44dad5a5ea230790db15435147 to your computer and use it in GitHub Desktop.
Save rys/b6009b44dad5a5ea230790db15435147 to your computer and use it in GitHub Desktop.
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{
"version": "https://jsonfeed.org/version/1.1",
"title": {{ .Site.Title | jsonify }},
"home_page_url": {{ .Site.BaseURL | jsonify }},
{{ with .OutputFormats.Get "json" -}}
"feed_url": {{ .Permalink | jsonify }},
{{- end }}
"description": {{ .Site.Title | jsonify }},
"authors": [{
"name": {{ .Site.Author.name | jsonify }},
"url": "https://rys.sommefeldt.uk/",
"avatar": "https://work.sommefeldt.com/img/avatar.jpg"
}],
"items": [
{{ range $index, $element := $pages }}
{{ if $index }},{{ end }} {
"id": {{ .Permalink | jsonify }},
"url": {{ .Permalink | jsonify }},
"title": {{ .Title | jsonify }},
"content_html": {{ .Content | jsonify }},
"summary": {{ .Summary | jsonify }},
"date_published": {{ .Date.Format "2006-01-02T15:04:05Z07:00" | jsonify }}
}
{{ end }}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment