Skip to content

Commit

Permalink
remove some blog-related junk, fix RSS feed (sveltejs#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Jun 19, 2024
1 parent e91be0f commit b26db5a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 122 deletions.
84 changes: 0 additions & 84 deletions apps/svelte.dev/src/lib/server/blog/index.js

This file was deleted.

27 changes: 0 additions & 27 deletions apps/svelte.dev/src/lib/server/blog/types.d.ts

This file was deleted.

18 changes: 8 additions & 10 deletions apps/svelte.dev/src/routes/blog/rss.xml/+server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { get_blog_data, get_blog_list } from '$lib/server/blog/index.js';
import { index } from '$lib/server/content';

export const prerender = false; // TODO

Expand All @@ -24,7 +24,7 @@ function escapeHTML(html) {
return html.replace(/["'&<>]/g, (c) => `&${chars[c]};`);
}

/** @param {import('$lib/server/blog/types').BlogPostSummary[]} posts */
/** @param {import('@sveltejs/site-kit').Document[]} posts */
const get_rss = (posts) =>
`
<?xml version="1.0" encoding="UTF-8" ?>
Expand All @@ -40,14 +40,14 @@ const get_rss = (posts) =>
<link>https://svelte.dev/blog</link>
</image>
${posts
.filter((post) => !post.draft)
.filter((post) => !post.metadata.draft)
.map(
(post) => `
<item>
<title>${escapeHTML(post.title)}</title>
<link>https://svelte.dev/blog/${post.slug}</link>
<description>${escapeHTML(post.description)}</description>
<pubDate>${formatPubdate(post.date)}</pubDate>
<title>${escapeHTML(post.metadata.title)}</title>
<link>https://svelte.dev/${post.slug}</link>
<description>${escapeHTML(post.metadata.description)}</description>
<pubDate>${formatPubdate(/** @type {string} */ (post.file.split('/').pop()).slice(0, 10))}</pubDate>
</item>
`
)
Expand All @@ -61,9 +61,7 @@ const get_rss = (posts) =>
.trim();

export async function GET() {
const posts = get_blog_list(await get_blog_data());

return new Response(get_rss(posts), {
return new Response(get_rss(index.blog.children), {
headers: {
'Cache-Control': `max-age=${30 * 60 * 1e3}`,
'Content-Type': 'application/rss+xml'
Expand Down
1 change: 0 additions & 1 deletion apps/svelte.dev/src/routes/nav.json/+server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { get_blog_data, get_blog_list } from '$lib/server/blog/index.js';
import { get_docs_data, get_docs_list } from '$lib/server/docs/index.js';
import { get_examples_list } from '$lib/server/examples/index.js';
import examples_data from '$lib/generated/examples-data.js';
Expand Down

0 comments on commit b26db5a

Please sign in to comment.