diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 8275569..ff0efcb 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -8,7 +8,6 @@ export interface Metadata { export interface Section { poetry: 'poetry'; thoughts: 'thoughts'; - services: 'services'; all: 'all'; } diff --git a/src/routes/(app)/poetry/+page.svelte b/src/routes/(app)/poetry/+page.svelte index 6dc8d16..d8e616b 100644 --- a/src/routes/(app)/poetry/+page.svelte +++ b/src/routes/(app)/poetry/+page.svelte @@ -70,20 +70,18 @@ {/each} - {#if total > 1} - - {/if} + {/if} diff --git a/src/routes/(app)/poetry/rss/+server.ts b/src/routes/(app)/poetry/rss/+server.ts new file mode 100644 index 0000000..8977ae5 --- /dev/null +++ b/src/routes/(app)/poetry/rss/+server.ts @@ -0,0 +1,43 @@ +import { fetchMarkdownPosts, type Post } from '$lib/utils'; + +const siteURL = 'https://silentsilas.com'; +const siteTitle = 'silentsilas - Poetry'; +const siteDescription = 'Read some bad poetry.'; + +export const prerender = true; + +export const GET = async () => { + const { posts } = await fetchMarkdownPosts('poetry'); + + const body = render(posts); + const options = { + headers: { + 'Cache-Control': 'max-age=0, s-maxage=3600', + 'Content-Type': 'application/xml' + } + }; + + return new Response(body, options); +}; + +const render = (posts: Post[]) => ` + + +${siteTitle} +${siteDescription} +${siteURL} + +${posts + .map( + (post) => ` +${siteURL}/${post.section}/${post.filename} +${post.meta.title} +${siteURL}/${post.section}/${post.filename} +${post.meta.title} +${new Date(post.meta.date).toUTCString()} +` + ) + .join('')} + + +`; diff --git a/src/routes/(app)/rss/+server.ts b/src/routes/(app)/rss/+server.ts new file mode 100644 index 0000000..d924bf4 --- /dev/null +++ b/src/routes/(app)/rss/+server.ts @@ -0,0 +1,43 @@ +import { fetchMarkdownPosts, type Post } from '$lib/utils'; + +const siteURL = 'https://silentsilas.com'; +const siteTitle = 'silentsilas - Thoughts & Poems'; +const siteDescription = 'Read some bad takes and poetry.'; + +export const prerender = true; + +export const GET = async () => { + const { posts } = await fetchMarkdownPosts('all'); + + const body = render(posts); + const options = { + headers: { + 'Cache-Control': 'max-age=0, s-maxage=3600', + 'Content-Type': 'application/xml' + } + }; + + return new Response(body, options); +}; + +const render = (posts: Post[]) => ` + + +${siteTitle} +${siteDescription} +${siteURL} + +${posts + .map( + (post) => ` +${siteURL}/${post.section}/${post.filename} +${post.meta.title} +${siteURL}/${post.section}/${post.filename} +${post.meta.title} +${new Date(post.meta.date).toUTCString()} +` + ) + .join('')} + + +`; diff --git a/src/routes/(app)/thoughts/rss/+server.ts b/src/routes/(app)/thoughts/rss/+server.ts new file mode 100644 index 0000000..2b6ed62 --- /dev/null +++ b/src/routes/(app)/thoughts/rss/+server.ts @@ -0,0 +1,43 @@ +import { fetchMarkdownPosts, type Post } from '$lib/utils'; + +const siteURL = 'https://silentsilas.com'; +const siteTitle = 'silentsilas - Thoughts'; +const siteDescription = 'Read some bad takes.'; + +export const prerender = true; + +export const GET = async () => { + const { posts } = await fetchMarkdownPosts('thoughts'); + + const body = render(posts); + const options = { + headers: { + 'Cache-Control': 'max-age=0, s-maxage=3600', + 'Content-Type': 'application/xml' + } + }; + + return new Response(body, options); +}; + +const render = (posts: Post[]) => ` + + +${siteTitle} +${siteDescription} +${siteURL} + +${posts + .map( + (post) => ` +${siteURL}/${post.section}/${post.filename} +${post.meta.title} +${siteURL}/${post.section}/${post.filename} +${post.meta.title} +${new Date(post.meta.date).toUTCString()} +` + ) + .join('')} + + +`;