Add RSS feed functionality and update footer with RSS link

This commit is contained in:
Krem 2025-10-07 18:40:37 +02:00
parent 03a62f59c1
commit 655d43265f
2 changed files with 27 additions and 0 deletions

View File

@ -1,5 +1,6 @@
--- ---
import Social from "@components/common/Social.astro"; import Social from "@components/common/Social.astro";
import { FiRss } from 'react-icons/fi';
--- ---
<footer class="glass container lg:my-4 lg:rounded-lg intersect:animate-fadeUp opacity-0"> <footer class="glass container lg:my-4 lg:rounded-lg intersect:animate-fadeUp opacity-0">
@ -22,6 +23,10 @@ import Social from "@components/common/Social.astro";
linkedIn: "https://www.linkedin.com/in/kristian-emil-takvam-70a475215/", linkedIn: "https://www.linkedin.com/in/kristian-emil-takvam-70a475215/",
}} }}
/> />
<a href="/rss.xml" target="_blank" rel="noopener" class="text-orange-500 hover:text-orange-400">
<FiRss size={24} />
</a>
</div> </div>
</div> </div>
</footer> </footer>

22
src/pages/rss.xml.js Normal file
View File

@ -0,0 +1,22 @@
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
export async function GET(context) {
// Load all blog posts from your "blog" content collection
const posts = await getCollection('blog');
return rss({
title: 'Kristian Takvam — Blog',
description: 'Updates, notes, and thoughts by Kristian Takvam.',
site: context.site, // automatically pulls your "site" from astro.config.mjs
items: posts.map((post) => ({
title: post.data.title,
pubDate: post.data.date,
description: post.data.description,
link: `/blog/${post.slug}/`,
})),
customData: `<language>en-us</language>`,
});
}