This commit is contained in:
小赵同学 committed 2024-07-28 19:25:01 +08:00
1 parent 1d937f4077
commit 176fa2c868
10 files changed
+1980 -1542

No files matched your search

+33 -25
View File
@@ -1,43 +1,51 @@
{{- /* 定义页面上下文 */ -}}
{{- $page_context := cond .IsHome site . -}}
{{- $pages := $page_context.RegularPages -}}
{{- /* 过滤只包含类型为 'post' 的页面 */ -}}
{{- $pages = where $pages "Type" "post" -}}
{{- $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 -}}
{{- $limit := site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = first $limit $pages -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
{{- 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/">
<channel>
<title>{{ if ne .Title site.Title }}{{ with .Title }}{{.}} | {{ end }}{{end}}{{ site.Title }}</title>
<title>{{ site.Title }}</title>
<link>{{ .Permalink }}</link>
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end -}}
<description>{{ .Title | default site.Title }}</description>
<generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator>
{{- with site.LanguageCode }}<language>{{.}}</language>{{end -}}
{{- with site.Copyright }}<copyright>{{ replace (replace . "{year}" now.Year) "&copy;" "©" | plainify }}</copyright>{{end -}}
{{- if not .Date.IsZero }}<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end -}}
{{- if .Scratch.Get "og_image" }}
<description>{{ .Params.description }}</description>
{{- with site.Params.logo }}
<image>
<url>{{ .Scratch.Get "og_image" }}</url>
<title>{{ .Title | default site.Title }}</title>
<link>{{ .Permalink }}</link>
<url>{{ .icon | absURL }}</url>
<link>{{ .icon | absURL }}</link>
</image>
{{end -}}
{{- 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 -}}
{{ range $pages }}
{{- if and (ne .Layout `search`) (ne .Layout `archives`) }}
<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><![CDATA[
{{ .Content | safeHTML }}
]]></description>
<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 }}
</item>
{{- end }}
{{ end }}
</channel>
</rss>