all-posts page, page titles, index page

This commit is contained in:
2026-03-30 05:27:41 -04:00
parent 5ffb51d5ce
commit fd8ed38572
6 changed files with 126 additions and 7 deletions

View File

@@ -5,7 +5,8 @@ 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())
// unlike `/index` and `/posts`, we want to sort ascending by date here
entries.sort((a, b) => a.data.date.getTime() - b.data.date.getTime());
// for each route, the page gets passed the entry itself, plus the previous and next slugs
// (if any), so that it can render links to them
@@ -20,8 +21,9 @@ export async function getStaticPaths() {
}
const { entry, prevSlug, nextSlug } = Astro.props;
---
<BaseLayout>
<Post {...Astro.props} />
<BaseLayout pageTitle={entry.data.title}>
<Post {entry} {prevSlug} {nextSlug} />
</BaseLayout>