Skip to content

Commit e9e2fb2

Browse files
committed
Cleaner formatting of RSS XML
1 parent b459c91 commit e9e2fb2

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/common/BlogApi.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ function toXmlString(siteTitleOpt, siteDescriptionOpt, items) {
8585
var itemsStr = Belt_Array.reduce(items, "", (function (acc, item) {
8686
var description = item.description;
8787
var href = item.href;
88-
var descriptionElement = description === "" ? "" : "<description>\n <![CDATA[" + description + "]]>\n </description>\n ";
88+
var descriptionElement = description === "" ? "" : "<description>\n <![CDATA[" + description + "]]>\n </description>";
8989
var dateStr = dateToUTCString(item.pubDate);
90-
return acc + ("\n <item>\n <title> <![CDATA[" + item.title + "]]></title>\n <link> " + href + " </link>\n <guid> " + href + " </guid>\n " + descriptionElement + "\n\n <pubDate>" + dateStr + "</pubDate>\n\n </item>");
90+
return acc + ("\n <item>\n <title> <![CDATA[" + item.title + "]]></title>\n <link> " + href + " </link>\n <guid> " + href + " </guid>\n " + descriptionElement + "\n <pubDate>" + dateStr + "</pubDate>\n </item>");
9191
}));
92-
return "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n <rss version=\"2.0\">\n <channel>\n <title>" + siteTitle + "</title>\n <link>https://rescript-lang.org</link>\n <description>" + siteDescription + "</description>\n <language>en</language>\n " + latestPubDateElement + "\n " + itemsStr + "\n\n </channel>\n </rss>";
92+
return "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n <rss version=\"2.0\">\n <channel>\n <title>" + siteTitle + "</title>\n <link>https://rescript-lang.org</link>\n <description>" + siteDescription + "</description>\n <language>en</language>\n " + latestPubDateElement + "\n" + itemsStr + "\n </channel>\n </rss>";
9393
}
9494

9595
var RssFeed = {

src/common/BlogApi.res

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,8 @@ module RssFeed = {
144144
let descriptionElement = switch description {
145145
| "" => ""
146146
| desc => j`<description>
147-
<![CDATA[$desc]]>
148-
</description>
149-
`
147+
<![CDATA[$desc]]>
148+
</description>`
150149
}
151150

152151
// TODO: convert pubdate to string
@@ -157,10 +156,8 @@ module RssFeed = {
157156
<link> $href </link>
158157
<guid> $href </guid>
159158
$descriptionElement
160-
161159
<pubDate>$dateStr</pubDate>
162-
163-
</item>`
160+
</item>`
164161
})
165162

166163
let ret = j`<?xml version="1.0" encoding="utf-8" ?>
@@ -171,8 +168,7 @@ module RssFeed = {
171168
<description>$siteDescription</description>
172169
<language>en</language>
173170
$latestPubDateElement
174-
$itemsStr
175-
171+
$itemsStr
176172
</channel>
177173
</rss>` //rescript-lang.org</link>
178174

0 commit comments

Comments
 (0)