diff options
author | Yu Zhang <pseudoyu@connect.hku.hk> | 2022-07-04 16:04:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-04 16:04:00 +0300 |
commit | f420b491a01699b8b97ee0a148f29fe14476209c (patch) | |
tree | 5fedc0dfc2c71bf1a042c42d80525ebf22d2bda0 | |
parent | 34aadcf2c0f0a588bb47da9f9f05da1fdd6214bb (diff) |
* feat: optimize rss output format and add rss ignored support
I optimized the rss format accoring to hugo best practice and add "rss_ignore" prarm to manually
ignore some pages to to fetched by rss readers
* fix: change some settings to keep original features and make it backward-compatible
* revert: reverted to orginal version to keep the icon
* fix: keep both webfeeds and content in rss settings
-rw-r--r-- | layouts/rss.xml | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/layouts/rss.xml b/layouts/rss.xml index 444a1ee..57b9002 100644 --- a/layouts/rss.xml +++ b/layouts/rss.xml @@ -11,7 +11,7 @@ {{- $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" xmlns:webfeeds="http://webfeeds.org/rss/1.0"> +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:webfeeds="http://webfeeds.org/rss/1.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"> <channel> <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> <link>{{ .Permalink }}</link> @@ -28,19 +28,18 @@ {{ with .OutputFormats.Get "RSS" }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ end }} - {{ range $pages }} + {{ range $pages }}{{ if ne .Params.rss_ignore true }} <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> - {{ if .Site.Params.rssFullContent }} - <description>{{ .Content | html }}</description> - {{ else }} - <description>{{ .Summary | html }}</description> - {{ end }} + <description>{{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}}</description> + {{- if .Site.Params.rssFullContent}} + <content:encoded>{{ (printf "<![CDATA[%s]]>" .Content) | safeHTML }}</content:encoded> + {{- end }} </item> - {{ end }} + {{ end }}{{ end }} </channel> -</rss> +</rss>
\ No newline at end of file |