-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert blog posts to content collections
It *probably* works but the site doesn't build yet
- Loading branch information
1 parent
df0c20d
commit aaeae5f
Showing
4 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
import PostInfo from "@atoms/PostInfo.astro"; | ||
import Default from "@layouts/Default.astro"; | ||
import { getCollection, type CollectionEntry } from "astro:content"; | ||
import type { BaseProps } from "@layouts/Base.astro"; | ||
import Post from "@layouts/Post.astro"; | ||
interface Props { | ||
blogPost: CollectionEntry<"blog"> | ||
} | ||
export async function getStaticPaths() { | ||
const blogPosts = await getCollection("blog"); | ||
return blogPosts.map((blogPost) => ({ | ||
params: { slug: blogPost.slug }, | ||
props: { blogPost }, | ||
})); | ||
} | ||
const { blogPost } = Astro.props; | ||
const { Content } = await blogPost.render(); | ||
const contentProps: BaseProps = { | ||
title: blogPost.data.title, | ||
date: blogPost.data.date.toUTCString() | ||
} | ||
--- | ||
|
||
<Default content={contentProps}> | ||
<div class="blog-post"> | ||
<h1>{blogPost.data.title}</h1> | ||
<PostInfo authors={blogPost.data.authors} date={blogPost.data.date} /> | ||
|
||
<Content /> | ||
</div> | ||
</Default> |
This file was deleted.
Oops, something went wrong.