feat(): Inferred types for blogs instead of static.

This commit is contained in:
kami
2026-03-04 04:51:58 +08:00
parent 7c8b1b8223
commit d3e3f50606
2 changed files with 20 additions and 8 deletions

View File

@@ -1,16 +1,21 @@
---
import { getCollection, render } from 'astro:content';
import BlogPost from '@layouts/BlogPost.astro';
import type {
InferGetStaticParamsType,
InferGetStaticPropsType,
GetStaticPaths,
} from "astro";
export async function getStaticPaths() {
export const getStaticPaths = (async () => {
const posts = await getCollection('uni');
return posts.map(post => ({
params: { id: post.id },
props: { post },
}));
}
type Props = CollectionEntry<'blog'>;
}) satisfies GetStaticPaths;
type Params = InferGetStaticParamsType<typeof getStaticPaths>;
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
const { post } = Astro.props;
const { Content } = await render(post);