mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-29 08:32:05 +01:00
Merge pull request #2087 from sveltejs/gh-2085
fix invalid blog rss feed
This commit is contained in:
commit
845dd47fe8
@ -1,10 +1,10 @@
|
||||
import get_posts from '../api/blog/_posts.js';
|
||||
|
||||
const months = ',Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split( ',' );
|
||||
const months = ',Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(',');
|
||||
|
||||
function formatPubdate ( str ) {
|
||||
const [ y, m, d ] = str.split( '-' );
|
||||
return `${d} ${months[+m]} ${y}`;
|
||||
function formatPubdate(str) {
|
||||
const [y, m, d] = str.split('-');
|
||||
return `${d} ${months[+m]} ${y} 12:00 +0000`;
|
||||
}
|
||||
|
||||
const rss = `
|
||||
@ -20,18 +20,18 @@ const rss = `
|
||||
<title>Svelte</title>
|
||||
<link>https://svelte.technology/blog</link>
|
||||
</image>
|
||||
${get_posts().map( post => `
|
||||
${get_posts().map(post => `
|
||||
<item>
|
||||
<title>${post.metadata.title}</title>
|
||||
<link>https://svelte.technology/blog/${post.slug}</link>
|
||||
<description>${post.metadata.description}</description>
|
||||
<pubDate>${formatPubdate(post.metadata.pubdate)}</pubDate>
|
||||
</item>
|
||||
` )}
|
||||
`).join('')}
|
||||
</channel>
|
||||
|
||||
</rss>
|
||||
`.replace( />[^\S]+/gm, '>' ).replace( /[^\S]+</gm, '<' ).trim();
|
||||
`.replace(/>[^\S]+/gm, '>').replace(/[^\S]+</gm, '<').trim();
|
||||
|
||||
export function get(req, res) {
|
||||
res.set({
|
||||
@ -39,4 +39,4 @@ export function get(req, res) {
|
||||
'Content-Type': 'application/rss+xml'
|
||||
});
|
||||
res.end(rss);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user