list.json.json 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. {{- $pctx := . -}}
  2. {{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
  3. {{- $pages := $pctx.RegularPages -}}
  4. {{- $limit := .Site.Config.Services.RSS.Limit -}}
  5. {{- if ge $limit 1 -}}
  6. {{- $pages = $pages | first $limit -}}
  7. {{- end -}}
  8. {{ $length := (len $pages) -}}
  9. {
  10. "version" : "https://jsonfeed.org/version/1",
  11. "title" : "{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} {{ i18n "string_on" }} {{ end }}{{ .Site.Title }}{{ end }}",
  12. "description": "{{ i18n "string_recent_content" }} {{ if ne .Title .Site.Title }}{{ with .Title }}{{ i18n "string_in" }} {{ . }} {{ end }}{{ end }}{{ i18n "string_on" }} {{ .Site.Title }}",
  13. "home_page_url" : "{{ .Site.BaseURL }}",
  14. {{ with .OutputFormats.Get "JSON" -}}
  15. "feed_url" : "{{ .Permalink }}",
  16. {{ end -}}
  17. {{ with $.Param "icon" -}}
  18. "icon" : "{{ . | absURL }}",
  19. {{ end -}}
  20. {{ with $.Param "favicon" -}}
  21. "favicon" : "{{ . | absURL }}",
  22. {{ end -}}
  23. {{ with .Site.Author.name -}}
  24. "author" : {
  25. "name" : "{{ . }}"{{ with $.Site.Author.url }},
  26. "url": "{{ . }}"{{ end }}{{ with $.Site.Author.avatar }},
  27. "avatar": "{{ . | absURL }}"{{ end }}
  28. },
  29. {{ end -}}
  30. "items" : [
  31. {{ range $index, $element := $pages -}}
  32. {
  33. "title" : {{ .Title | jsonify }},
  34. "date_published" : "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}",
  35. "date_modified" : "{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}",
  36. "id" : "{{ .Permalink }}",
  37. "url" : "{{ .Permalink }}",
  38. {{ with .Params.author -}}
  39. "author" : {
  40. "name" : "{{ . }}"
  41. },
  42. {{ end -}}
  43. "content_html" : {{ .Content | jsonify }}
  44. }{{ if ne (add $index 1) $length }},{{ end }}
  45. {{ end -}}
  46. ]
  47. }