diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index cbabb4b..b618c3e 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -1,6 +1,9 @@ import { getCollection } from "astro:content"; import rss from "@astrojs/rss"; import type { APIRoute } from "astro"; +import { experimental_AstroContainer } from "astro/container"; + +const container = await experimental_AstroContainer.create(); export const GET: APIRoute = async ({ site }) => { const posts = await getCollection("blog"); @@ -11,15 +14,23 @@ export const GET: APIRoute = async ({ site }) => { site: site?.toString() ?? "", items: await Promise.all( posts.map(async (post) => { - const content = "TODO"; - - return { + const res = { title: post.data.title, description: post.data.bio, pubDate: post.data.pub, link: `/blog/${post.id}/`, - content: content, }; + + if (post.filePath) { + /* its ssg so dynamic imports are fine. + ../../ is bc it includes src/components + so we need to go to project root */ + /* @vite-ignore */ + const { default: Component } = await import(`../../${post.filePath}`); + const content = await container.renderToString(Component); + + return { ...res, content: content }; + } else return res; }), ), // stylesheet: ``,