Skip to content

Commit

Permalink
fix: format date according to RFC-822
Browse files Browse the repository at this point in the history
0xHericles committed Nov 17, 2023
1 parent 222367d commit 15c6f41
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions handlers/feed.ts
Original file line number Diff line number Diff line change
@@ -35,12 +35,14 @@ function generateItemXML(post: Post, locale: SupportedLocales): string {
img,
} = post;

const pubDate = new Date(date).toUTCString();

return `
<item>
<title>${xmlEncode(body[locale]?.title ?? "")}</title>
<link>https://deco.cx/blog${getBlogPath(path, locale)}</link>
<link>https://deco.cx${getBlogPath(path, locale)}</link>
<description>${xmlEncode(body[locale]?.descr ?? "")}</description>
<pubDate>${date}</pubDate>
<pubDate>${pubDate}</pubDate>
<author>${xmlEncode(author)}</author>
<authorAvatar>${xmlEncode(authorAvatar)}</authorAvatar>
<authorRole>${xmlEncode(authorRole)}</authorRole>
@@ -62,7 +64,7 @@ export default function BlogRSS({
.map((post: Post) => generateItemXML(post, locale))
.join("\n");

const rssHeader = `<?xml version="1.0" encoding="UTF-8" ?>
const rss = `<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>${title}</title>
@@ -74,7 +76,7 @@ export default function BlogRSS({
</channel>
</rss>`;

return new Response(rssHeader, {
return new Response(rss, {
headers: {
"content-type": "text/xml",
},

0 comments on commit 15c6f41

Please sign in to comment.