Created
May 19, 2017 22:08
-
-
Save voidfiles/302e8d690a5ef4990e371ce70bca3240 to your computer and use it in GitHub Desktop.
Hugo JSON Feed Template add to layouts/index.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "https://jsonfeed.org/version/1", | |
"title": {{ .Site.Title | jsonify }}, | |
"home_page_url": {{ .Permalink | jsonify }}, | |
{{ with .OutputFormats.Get "json" -}} | |
"feed_url": {{ .Permalink | jsonify }}, | |
{{- end }} | |
{{ if (.Site.Params.author) or (.Site.Params.author_url) -}} | |
"author": { | |
{{ if .Site.Params.author -}} | |
"name": {{ .Site.Params.author | jsonify }}, | |
{{- end }} | |
{{ if .Site.Params.author_url -}} | |
"url": {{ .Site.Params.author_url | jsonify }} | |
{{- end }} | |
}, | |
{{- end }} | |
{{ if .Data.Pages }} | |
"items": [ | |
{{ range $index, $element := first 10 .Data.Pages }} | |
{{if $index }},{{end}} { | |
"title": {{ $element.Title | jsonify }}, | |
"id": {{ $element.Permalink | jsonify }}, | |
"url": {{ $element.Permalink | jsonify }}, | |
"content_html": {{ $element.Content | jsonify }}, | |
"date_published": {{ $element.Date.Format "2006-02-01T15:04:05-0700" | jsonify }} | |
} | |
{{ end }} | |
] | |
{{ end }} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment