Move to Astro
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
---
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection("blog");
|
||||
return blogEntries.map((entry) => ({
|
||||
params: { slug: entry.slug },
|
||||
props: { entry },
|
||||
}));
|
||||
}
|
||||
|
||||
const { entry } = Astro.props;
|
||||
const { Content } = await entry.render();
|
||||
---
|
||||
|
||||
<Content />
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
import Layout from "../layouts/TitleLayout.astro";
|
||||
import FrontPageLink from "../components/FrontPageLink.astro";
|
||||
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
const allBlogPosts = await getCollection("blog");
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<main>
|
||||
<div class="container">
|
||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3">
|
||||
{
|
||||
allBlogPosts
|
||||
.sort((a, b) => {
|
||||
return (
|
||||
new Date(a.data.date).getTime() -
|
||||
new Date(b.data.date).getTime()
|
||||
);
|
||||
})
|
||||
.map((b) => (
|
||||
<FrontPageLink
|
||||
href={b.slug}
|
||||
title={b.data.title}
|
||||
imageSrc={b.data.image}
|
||||
description={b.data.description}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</Layout>
|
||||
|
||||
<style></style>
|
||||
@@ -0,0 +1,17 @@
|
||||
import rss from "@astrojs/rss";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function get(context: any) {
|
||||
const blog = await getCollection("blog");
|
||||
return rss({
|
||||
title: "Nozzy House News",
|
||||
description: "What's going on in the Nozzy house",
|
||||
site: context.site,
|
||||
items: blog.map((post) => ({
|
||||
title: post.data.title,
|
||||
pubDate: post.data.date,
|
||||
description: `In which ${post.data.description}`,
|
||||
link: post.slug,
|
||||
})),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user