mirror of
https://github.com/jbowdre/runtimeterror.git
synced 2024-12-24 03:42:19 +00:00
add templates for rss/json output
This commit is contained in:
parent
5afe7a49c7
commit
32bf552281
2 changed files with 62 additions and 0 deletions
7
layouts/_default/index.json
Normal file
7
layouts/_default/index.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{- $.Scratch.Add "index" slice -}}
|
||||
{{- range .Site.Pages -}}
|
||||
{{- if ne .Type "search" -}}
|
||||
{{- $.Scratch.Add "index" (dict "title" .Title "body" .Plain "link" .Permalink "section" .Section "tags" .Params.tags) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- jsonify (uniq ($.Scratch.Get "index")) -}}
|
55
layouts/_default/rss.xml
Normal file
55
layouts/_default/rss.xml
Normal file
|
@ -0,0 +1,55 @@
|
|||
{{- $pctx := . -}}
|
||||
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
|
||||
{{- $pages := slice -}}
|
||||
{{- if or $.IsHome $.IsSection -}}
|
||||
{{- $pages = (where $pctx.RegularPages "Type" "in" site.Params.mainSections) -}}
|
||||
{{- else -}}
|
||||
{{- $pages = (where $pctx.Pages "Type" "in" site.Params.mainSections) -}}
|
||||
{{- end -}}
|
||||
{{- $limit := .Site.Config.Services.RSS.Limit -}}
|
||||
{{- if ge $limit 1 -}}
|
||||
{{- $pages = $pages | first $limit -}}
|
||||
{{- end -}}
|
||||
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
|
||||
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
|
||||
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
|
||||
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
|
||||
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
|
||||
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
|
||||
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
|
||||
{{- with .OutputFormats.Get "RSS" -}}
|
||||
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
|
||||
{{- end -}}
|
||||
{{ range $pages }}
|
||||
<item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
|
||||
<guid>{{ .Permalink }}</guid>
|
||||
<description>
|
||||
{{ if ne site.Params.rss_summary false }}
|
||||
{{ if .Params.summary }}
|
||||
{{ .Params.summary | html }}
|
||||
{{ else if .Params.abstract }}
|
||||
{{ .Params.abstract | html }}
|
||||
{{ else if .Summary }}
|
||||
{{ .Summary | html }}
|
||||
{{ end }}
|
||||
{{ if site.Params.rss_summary_read_more_link }}
|
||||
{{ $trans := i18n "read_more" -}}
|
||||
{{ printf "<p><a href=\"%s\">%s</a></p>" .RelPermalink $trans | html }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ .Content | html }}
|
||||
{{ end }}
|
||||
</description>
|
||||
</item>
|
||||
{{ end }}
|
||||
</channel>
|
||||
</rss>
|
Loading…
Reference in a new issue