Skip to content

Commit

Permalink
chore(rss): beautify the description format via CDATA
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Sep 7, 2022
1 parent ac76917 commit f2e20f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion layouts/partials/rss.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
<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 default false $.Site.Params.feeds.contentAsDescription }}{{ .Content | html }}{{ else }}{{ .Summary | html }}{{ end }}</description>
<description>
{{- if default false $.Site.Params.feeds.contentAsDescription }}
{{- printf "<![CDATA[%s]]>" .Content | safeHTML }}
{{- else }}
{{- printf "<![CDATA[%s]]>" .Summary | safeHTML }}
{{- end }}
</description>
{{- partial "rss/enclosure" . }}
</item>
{{ end }}
Expand Down

2 comments on commit f2e20f0

@iamgiannisx
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replace line 37 to 43 with the code below

        <description>
        {{- printf "<![CDATA[%s]]>" .Summary | safeHTML }}
      </description>
        {{- if default false $.Site.Params.feeds.contentAsDescription }}
      <content:encoded>
        {{- printf "<![CDATA[%s]]>" .Content | safeHTML }}
      </content:encoded>
        {{- end }}

and line 16 with

<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">

This is a valid xml feed if you like to include full content.

@razonyang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamgiannisx thanks for pointing it out, but the <content:encoded> tags seems an extending element.

Please sign in to comment.