Files
blog/themes/Ying/layouts/_default/rss.xml
T

51 lines
2.4 KiB
XML
Raw Normal View History

2024-07-28 19:25:01 +08:00
{{- $pages := .Pages -}}
{{- if $.IsHome -}}
{{/* get all regular pages instead of pages in a section */}}
{{- $pages = where site.RegularPages "Section" "in" site.Params.mainSections -}}
{{- end }}
{{- $pages = where $pages "Params.hidden" "!=" true -}}
2024-07-28 18:29:37 +08:00
{{- $limit := site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
2024-07-28 19:25:01 +08:00
{{- $pages = $pages | first $limit -}}
2024-07-28 18:29:37 +08:00
{{- end -}}
2024-07-28 18:58:23 +08:00
2024-07-28 19:25:01 +08:00
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
2024-07-28 16:28:47 +08:00
<channel>
2024-07-28 19:25:01 +08:00
<title>{{ site.Title }}</title>
2024-07-28 17:27:15 +08:00
<link>{{ .Permalink }}</link>
2024-07-28 19:25:01 +08:00
<description>{{ .Params.description }}</description>
{{- with site.Params.logo }}
2024-07-28 18:29:37 +08:00
<image>
2024-07-28 19:25:01 +08:00
<url>{{ .icon | absURL }}</url>
<link>{{ .icon | absURL }}</link>
2024-07-28 18:29:37 +08:00
</image>
2024-07-28 19:25:01 +08:00
{{- end }}
<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 -}}
2024-07-28 18:29:37 +08:00
{{ range $pages }}
2024-07-28 19:25:01 +08:00
{{- if and (ne .Layout `search`) (ne .Layout `archives`) }}
2024-07-28 18:29:37 +08:00
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
2026-03-01 10:51:12 +08:00
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
2024-07-28 19:25:01 +08:00
{{ with site.Author.email }}<author>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</author>{{end}}
2026-03-01 10:51:12 +08:00
<guid isPermaLink="true">{{ .Permalink }}</guid>
2024-07-28 19:25:01 +08:00
<description>{{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}}</description>
{{- if not site.Params.RSSNoContent}}
{{ $image := printf `<img loading="lazy" decoding="async" src="%s" alt="%s" />` (.Params.image | relURL) .Title }}
<content:encoded>{{ (printf "<![CDATA[%s%s]]>" $image .Content) | safeHTML }}</content:encoded>
{{- end }}
2024-07-28 18:29:37 +08:00
</item>
2024-07-28 19:25:01 +08:00
{{- end }}
2024-07-28 16:28:47 +08:00
{{ end }}
</channel>
2024-07-28 17:27:15 +08:00
</rss>