add rss feeds (/rss, /poetry/rss, and /thoughts/rss)
This commit is contained in:
parent
e54a60359c
commit
dae681d2c2
|
@ -8,7 +8,6 @@ export interface Metadata {
|
||||||
export interface Section {
|
export interface Section {
|
||||||
poetry: 'poetry';
|
poetry: 'poetry';
|
||||||
thoughts: 'thoughts';
|
thoughts: 'thoughts';
|
||||||
services: 'services';
|
|
||||||
all: 'all';
|
all: 'all';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,6 @@
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
{#if total > 1}
|
|
||||||
<nav class="join justify-end py-10">
|
<nav class="join justify-end py-10">
|
||||||
<button
|
<button
|
||||||
class="join-item btn-primary btn btn-outline"
|
class="join-item btn-primary btn btn-outline"
|
||||||
|
@ -84,6 +83,5 @@
|
||||||
disabled={currentPage === totalPages}>Next</button
|
disabled={currentPage === totalPages}>Next</button
|
||||||
>
|
>
|
||||||
</nav>
|
</nav>
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -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[]) => `<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<channel>
|
||||||
|
<title>${siteTitle}</title>
|
||||||
|
<description>${siteDescription}</description>
|
||||||
|
<link>${siteURL}</link>
|
||||||
|
<atom:link href="${siteURL}/rss.xml" rel="self" type="application/rss+xml"/>
|
||||||
|
${posts
|
||||||
|
.map(
|
||||||
|
(post) => `<item>
|
||||||
|
<guid isPermaLink="true">${siteURL}/${post.section}/${post.filename}</guid>
|
||||||
|
<title>${post.meta.title}</title>
|
||||||
|
<link>${siteURL}/${post.section}/${post.filename}</link>
|
||||||
|
<description>${post.meta.title}</description>
|
||||||
|
<pubDate>${new Date(post.meta.date).toUTCString()}</pubDate>
|
||||||
|
</item>`
|
||||||
|
)
|
||||||
|
.join('')}
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
`;
|
|
@ -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[]) => `<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<channel>
|
||||||
|
<title>${siteTitle}</title>
|
||||||
|
<description>${siteDescription}</description>
|
||||||
|
<link>${siteURL}</link>
|
||||||
|
<atom:link href="${siteURL}/rss.xml" rel="self" type="application/rss+xml"/>
|
||||||
|
${posts
|
||||||
|
.map(
|
||||||
|
(post) => `<item>
|
||||||
|
<guid isPermaLink="true">${siteURL}/${post.section}/${post.filename}</guid>
|
||||||
|
<title>${post.meta.title}</title>
|
||||||
|
<link>${siteURL}/${post.section}/${post.filename}</link>
|
||||||
|
<description>${post.meta.title}</description>
|
||||||
|
<pubDate>${new Date(post.meta.date).toUTCString()}</pubDate>
|
||||||
|
</item>`
|
||||||
|
)
|
||||||
|
.join('')}
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
`;
|
|
@ -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[]) => `<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<channel>
|
||||||
|
<title>${siteTitle}</title>
|
||||||
|
<description>${siteDescription}</description>
|
||||||
|
<link>${siteURL}</link>
|
||||||
|
<atom:link href="${siteURL}/rss.xml" rel="self" type="application/rss+xml"/>
|
||||||
|
${posts
|
||||||
|
.map(
|
||||||
|
(post) => `<item>
|
||||||
|
<guid isPermaLink="true">${siteURL}/${post.section}/${post.filename}</guid>
|
||||||
|
<title>${post.meta.title}</title>
|
||||||
|
<link>${siteURL}/${post.section}/${post.filename}</link>
|
||||||
|
<description>${post.meta.title}</description>
|
||||||
|
<pubDate>${new Date(post.meta.date).toUTCString()}</pubDate>
|
||||||
|
</item>`
|
||||||
|
)
|
||||||
|
.join('')}
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
`;
|
Loading…
Reference in New Issue