Skip to content

Commit 845dd47

Browse files
authored
Merge pull request #2087 from sveltejs/gh-2085
fix invalid blog rss feed
2 parents d61616e + f262293 commit 845dd47

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

site/src/routes/blog/rss.xml.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import get_posts from '../api/blog/_posts.js';
22

3-
const months = ',Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split( ',' );
3+
const months = ',Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(',');
44

5-
function formatPubdate ( str ) {
6-
const [ y, m, d ] = str.split( '-' );
7-
return `${d} ${months[+m]} ${y}`;
5+
function formatPubdate(str) {
6+
const [y, m, d] = str.split('-');
7+
return `${d} ${months[+m]} ${y} 12:00 +0000`;
88
}
99

1010
const rss = `
@@ -20,23 +20,23 @@ const rss = `
2020
<title>Svelte</title>
2121
<link>https://svelte.technology/blog</link>
2222
</image>
23-
${get_posts().map( post => `
23+
${get_posts().map(post => `
2424
<item>
2525
<title>${post.metadata.title}</title>
2626
<link>https://svelte.technology/blog/${post.slug}</link>
2727
<description>${post.metadata.description}</description>
2828
<pubDate>${formatPubdate(post.metadata.pubdate)}</pubDate>
2929
</item>
30-
` )}
30+
`).join('')}
3131
</channel>
3232
3333
</rss>
34-
`.replace( />[^\S]+/gm, '>' ).replace( /[^\S]+</gm, '<' ).trim();
34+
`.replace(/>[^\S]+/gm, '>').replace(/[^\S]+</gm, '<').trim();
3535

3636
export function get(req, res) {
3737
res.set({
3838
'Cache-Control': `max-age=${30 * 60 * 1e3}`,
3939
'Content-Type': 'application/rss+xml'
4040
});
4141
res.end(rss);
42-
}
42+
}

0 commit comments

Comments
 (0)