mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-21 12:40:39 +00:00
60 lines
2.2 KiB
JSON
60 lines
2.2 KiB
JSON
{{- $title := .Site.Title -}}
|
|
{{- if not (eq .Kind "home") -}}
|
|
{{- $title = printf `%s on %s` (partial "utils/title" .) $title -}}
|
|
{{- end -}}
|
|
{
|
|
"version": "https://jsonfeed.org/version/1.1",
|
|
"title": {{ $title | jsonify }},
|
|
{{- with .Site.Params.subtitle }}
|
|
"description": {{ . | jsonify }},
|
|
{{- end }}
|
|
"home_page_url" : "{{ .Site.Home.Permalink }}",
|
|
{{- with .OutputFormats.Get "json" }}
|
|
"feed_url" : "{{ .Permalink }}",
|
|
{{- end }}
|
|
{{- with .Site.Params.geekblogAuthor -}}
|
|
{{ with index $.Site.Data.authors . }}
|
|
"authors" : [
|
|
{
|
|
"name" : "{{ .name }}"{{ with .url }},
|
|
"url": "{{ . }}"{{ end }}{{ with .avatar }},
|
|
"avatar": "{{ . }}"{{ end }}
|
|
}
|
|
],
|
|
{{- end }}
|
|
{{- end }}
|
|
"items" : [
|
|
{{- $pages := where .RegularPages "Type" "in" .Site.Params.mainSections -}}
|
|
{{- if (eq .Kind "home") -}}
|
|
{{- $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
|
|
{{- end -}}
|
|
{{- $len := (len $pages) }}
|
|
{{- range $i, $page := $pages }}
|
|
{
|
|
"title" : {{ (partial "utils/title" .) | jsonify }},
|
|
"date_published" : {{ (.Date.Format "2006-01-02T15:04:05Z07:00") | jsonify }},
|
|
"date_modified" : {{ (.Lastmod.Format "2006-01-02T15:04:05Z07:00") | jsonify }},
|
|
"id" : "{{ .Permalink }}",
|
|
"url" : "{{ .Permalink }}",
|
|
{{- with ($page.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }}
|
|
{{- $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) -}}
|
|
"image" : "{{ $featured.Permalink }}",
|
|
{{- end }}
|
|
{{- with .Params.authors -}}
|
|
"authors" : [
|
|
{{- $authors := (sort .) }}
|
|
{{- $authors_len := (len $authors) }}
|
|
{{- range $i, $element := $authors -}}
|
|
{{- $author := index $.Site.Data.authors $element }}
|
|
{
|
|
"name" : "{{ $author.name }}"
|
|
}{{ if ne (add $i 1) $authors_len }},{{ end }}
|
|
{{- end }}
|
|
],
|
|
{{- end }}
|
|
"content_html" : {{ .Content | jsonify }}
|
|
}{{ if ne (add $i 1) $len }},{{ end }}
|
|
{{- end }}
|
|
]
|
|
}
|