{{- $pctx := . -}} {{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} {{- $pages := slice -}} {{- if $.IsHome -}} {{- $mainSections := site.Params.mainSections | default (slice "posts") }} {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}} {{- else if $.IsSection -}} {{- $pages = $pctx.RegularPages.ByDate.Reverse -}} {{- else -}} {{- $pages = $pctx.Pages -}} {{- end -}} {{- $limit := site.Params.feedSize | default 25 -}} {{- $pages = $pages | first $limit -}} {{- $siteAuthor := partial "site-author.html" . -}} { "version": "https://jsonfeed.org/version/1.1", "title": {{ (partial "title.html" .) | htmlUnescape | jsonify }}, "home_page_url": {{ printf "%s?utm_source=json_feed" site.BaseURL | absURL | jsonify }}, {{ with .OutputFormats.Get "JSON" }}"feed_url": {{ .Permalink | absURL | jsonify }},{{ end }} {{ with site.Params.description}}"description": {{ site.Params.description | jsonify }},{{ end }} {{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png") }}{{ $logo = $logo.Resize "96x96" }} "icon": {{ $logo.Permalink | jsonify }}, "favicon": {{ $logo.Permalink | jsonify }}, {{ with $siteAuthor.name }}"authors": [ { "name": {{ . | jsonify }}{{ with $siteAuthor.twitter }}, "url": {{ (printf "https://twitter.com/%s" . ) | jsonify }}{{ end }} } ],{{ end }} {{ with site.LanguageCode }}"language" : "{{ . }}",{{ end }}{{ $feedsize := site.Params.feedSize | default 25 }} "items": [{{ range $i, $ := $pages }}{{ if $i }},{{ end }} { "id": {{ $uuid := sha1 (.Permalink | absURL)}}"{{substr $uuid 0 8}}-{{substr $uuid 8 4}}-5{{substr $uuid 13 3}}-{{substr $uuid 16 1}}9{{substr $uuid 17 2}}-{{substr $uuid 21 12}}", "url": {{ printf "%s?utm_source=json_feed" .Permalink | jsonify }}, "title": {{ .Title | plainify | chomp | jsonify }}, "summary": {{ .Summary | plainify | chomp | jsonify }}, "date_published": {{ .PublishDate.Format "2006-01-02T15:04:05Z07:00" | jsonify }}{{ if ne .Date .Lastmod }}, "date_modified" : {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | jsonify }}{{ end }} } {{- end }} ] }