hugo-theme-contentful/layouts/_default/list.json
2020-05-13 01:41:43 +08:00

32 lines
1.5 KiB
JSON

{
"version": "https://jsonfeed.org/version/1",
"title": "{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}",
"home_page_url": "{{ "" | absLangURL }}",
"feed_url": "{{ with .OutputFormats.Get "json" }}{{ .Permalink }}{{ end }}",
"description": "Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}",
{{- /* ICON, AHOY! */ -}}
"favicon": "{{ "icon.png" | absURL }}",
"icon": "{{ "icon.png" | absURL }}",
{{- with .Site.Author }}
"author": {
"name": "{{ .name }}"
{{- with .email }},
"url": "mailto:{{ . }}"
{{ end }}
},
{{- end }}
"items":
{{- $limit := cond (gt .Site.Params.feedLimit 0) .Site.Params.feedLimit 10 -}}
{{ $pages := .Pages }}
{{ if .IsHome }}
{{ $pages = where $.Site.RegularPages "Type" "in" $.Site.Params.mainSections }}
{{ end }}
{{- $.Scratch.Add "index" slice -}}
{{ range first $limit (where $pages "Params.hidden" "!=" true) }}
{{- $.Scratch.Add "index" (dict "id" .Permalink "url" .Permalink "title" .Title "summary" (.Summary | safeHTML) "content_html" (.Content | safeHTML) "tags" .Params.tags "date_published" (.Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML) "date_modified" ( .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML ) ) -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}
}