Skip to content

Commit 32e5a8d

Browse files
author
Farzad Hayatbakhsh
committed
DOC-2608: Normalize version if it's missing the minor or patch version
1 parent 3c275a7 commit 32e5a8d

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

lib/rssfeed.cjs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ module.exports.register = function ({ config }) {
3737
.map((_, element) => {
3838
const $element = $(element);
3939
const linkElement = $element.find("a.xref");
40-
const [version, date] = linkElement.text().split(" - ");
40+
let [version, date] = linkElement.text().split(" - ");
41+
42+
// Normalize version if it's missing the minor or patch version
43+
const versionParts = version.split(".");
44+
if (versionParts.length === 1) {
45+
version += ".0.0";
46+
} else if (versionParts.length === 2) {
47+
version += ".0";
48+
}
4149

4250
// Remove <p> tags inside <li> tags to fix rendering issues
4351
const contentElement = $element.find(".sectionbody");
@@ -63,32 +71,32 @@ module.exports.register = function ({ config }) {
6371
const rssItems = releases
6472
.map(
6573
({ title, link, description, guid, pubDate, content }) => `
66-
<item>
67-
<title>${title}</title>
68-
<link>${link}</link>
69-
<description>${description}</description>
70-
<guid isPermaLink="false">${guid}</guid>
71-
<pubDate>${pubDate}</pubDate>
72-
<content:encoded><![CDATA[${content}]]></content:encoded>
73-
</item>`
74+
<item>
75+
<title>${title}</title>
76+
<link>${link}</link>
77+
<description>${description}</description>
78+
<guid isPermaLink="false">${guid}</guid>
79+
<pubDate>${pubDate}</pubDate>
80+
<content:encoded><![CDATA[${content}]]></content:encoded>
81+
</item>`
7482
)
7583
.join("\n");
7684

7785
// Assemble the complete RSS feed
7886
const rss = `<?xml version="1.0" encoding="UTF-8" ?>
79-
<rss version="2.0"
80-
xmlns:atom="http://www.w3.org/2005/Atom"
81-
xmlns:content="http://purl.org/rss/1.0/modules/content/"
82-
>
83-
<channel>
84-
<title>${productName} ${productMajorVersion} ${pageTitle}</title>
85-
<link>${siteLinkWithVersion}/${pageName}</link>
86-
<description>${pageDescription}</description>
87-
<language>en</language>
88-
<atom:link href="${siteLink}/rss.xml" rel="self" type="application/rss+xml" />
89-
${rssItems}
90-
</channel>
91-
</rss>`;
87+
<rss version="2.0"
88+
xmlns:atom="http://www.w3.org/2005/Atom"
89+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
90+
>
91+
<channel>
92+
<title>${productName} ${productMajorVersion} ${pageTitle}</title>
93+
<link>${siteLinkWithVersion}/${pageName}</link>
94+
<description>${pageDescription}</description>
95+
<language>en</language>
96+
<atom:link href="${siteLink}/rss.xml" rel="self" type="application/rss+xml" />
97+
${rssItems}
98+
</channel>
99+
</rss>`;
92100

93101
// Add RSS feed to site catalog
94102
siteCatalog.addFile({

0 commit comments

Comments
 (0)