blog

My blog at www.shimmy1996.com

git clone git://git.shimmy1996.com/blog.git
commit 49fa53be988d16d13d40bc33a539fe7fa2370284
parent 33077d0b3b85841d54f01c0ab5c5340c96ff0439
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Mon, 13 Apr 2020 10:50:49 -0500

Use summary as title for titleless posts to make feed validate

Diffstat:
Mlayouts/rss.xml | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/layouts/rss.xml b/layouts/rss.xml
@@ -8,7 +8,10 @@
   {{ range (first 20 (where .Site.RegularPages "Section" "!=" "")) }}
   <entry>
     <id>{{ .Permalink }}</id>
-    {{ `<title type="html"><![CDATA[` | safeHTML }}{{ .Title }}]]></title>
+    {{ `<title type="html"><![CDATA[` | safeHTML -}}
+    {{- if .Title }}{{ .Title }}{{ else -}}
+    {{- truncate .Site.Params.summaryLength "…" (plainify .Content) }}{{ end -}}
+    {{- `]]></title>` | safeHTML -}}
     <updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" }}</updated>
     {{ `<content type="html"><![CDATA[` | safeHTML }}{{ .Content }}{{ partial "hyperskip_feed.html" . }}]]></content>
     <link href="{{ .Permalink }}"/>