start working on posts with placeholder content
This commit is contained in:
24
src/pages/[slug].astro
Normal file
24
src/pages/[slug].astro
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
import { getCollection } from 'astro:content';
|
||||
import BaseLayout from '@layouts/BaseLayout.astro';
|
||||
import Post from '@components/Post.astro';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const entries = await getCollection('posts');
|
||||
entries.sort((a, b) => a.data.date.getTime() - b.data.date.getTime())
|
||||
return entries.map((entry, idx) => {
|
||||
const prevSlug = entries[idx - 1]?.id || null;
|
||||
const nextSlug = entries[idx + 1]?.id || null;
|
||||
return {
|
||||
params: { slug: entry.id },
|
||||
props: { entry, prevSlug, nextSlug },
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
<BaseLayout>
|
||||
<Post {...Astro.props} />
|
||||
</BaseLayout>
|
||||
Reference in New Issue
Block a user