From 181547a25213bee8a20002e07344b957386c4d0f Mon Sep 17 00:00:00 2001 From: Pauline Date: Sun, 26 Nov 2023 22:55:04 -0500 Subject: feat(build): transfer everything to esm/ts --- apps/website/src/pages/blog/[...slug].astro | 25 ++++++++++++++++++++++++ apps/website/src/pages/blog/index.astro | 30 +++++++++++++++++++++++++++++ apps/website/src/pages/rss.xml.js | 16 +++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 apps/website/src/pages/blog/[...slug].astro create mode 100644 apps/website/src/pages/blog/index.astro create mode 100644 apps/website/src/pages/rss.xml.js (limited to 'apps/website/src/pages') diff --git a/apps/website/src/pages/blog/[...slug].astro b/apps/website/src/pages/blog/[...slug].astro new file mode 100644 index 0000000..d9995e7 --- /dev/null +++ b/apps/website/src/pages/blog/[...slug].astro @@ -0,0 +1,25 @@ +--- +// i hate u astro vscode extensi on/j +/// +import { type CollectionEntry, getCollection } from 'astro:content'; +import BlogPost from '../../layouts/BlogPost.astro'; + +export async function getStaticPaths() { + const posts = await getCollection('blog'); + return posts.map(post => ({ + params: { slug: post.slug }, + props: post, + })); +} + +type Props = CollectionEntry<'blog'>; + +const post = Astro.props; +const { Content } = await post.render(); +--- + + + + + + diff --git a/apps/website/src/pages/blog/index.astro b/apps/website/src/pages/blog/index.astro new file mode 100644 index 0000000..c8f8203 --- /dev/null +++ b/apps/website/src/pages/blog/index.astro @@ -0,0 +1,30 @@ +--- +/// +import Layout from '../../layouts/Layout.astro'; +import FormattedDate from '../../components/base/FormattedDate.astro' +import { getCollection } from 'astro:content'; + +const posts = (await getCollection('blog')).sort( + (a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf() +); +--- + + +
+ +
+
diff --git a/apps/website/src/pages/rss.xml.js b/apps/website/src/pages/rss.xml.js new file mode 100644 index 0000000..fe05755 --- /dev/null +++ b/apps/website/src/pages/rss.xml.js @@ -0,0 +1,16 @@ +import rss from '@astrojs/rss'; +import { getCollection } from 'astro:content'; + +export async function GET(context) { + const posts = await getCollection('blog'); + + return rss({ + title: 'Polyfrost Blog', + description: 'Recieve Polyfrost updates here', + site: context.site, + items: posts.map(post => ({ + ...post.data, + link: `/blog/${post.slug}/`, + })), + }); +} -- cgit