First release.
This commit is contained in:
34
src/pages/article/blog/[...blog].astro
Normal file
34
src/pages/article/blog/[...blog].astro
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import type {
|
||||
CollectionEntry,
|
||||
CollectionKey,
|
||||
ContentEntryMap,
|
||||
} from "astro:content";
|
||||
import Footer from "../../../components/Footer.astro";
|
||||
import Nav from "../../../components/Nav.astro";
|
||||
import ArticleBody from "../../../components/article/ArticleBody.astro";
|
||||
import DefaultLayout from "../../../layouts/DefaultLayout.astro";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const collectionName: CollectionKey = "blog";
|
||||
const blogEntries = await getCollection(collectionName);
|
||||
return blogEntries.map((entry) => ({
|
||||
params: { blog: entry.slug },
|
||||
props: { entry },
|
||||
}));
|
||||
}
|
||||
|
||||
interface Props {
|
||||
entry: CollectionEntry<keyof ContentEntryMap>;
|
||||
}
|
||||
const { entry } = Astro.props;
|
||||
|
||||
const articlePrettyName:string = entry.id.split("/").pop()!.replace(".md", "");
|
||||
---
|
||||
|
||||
<DefaultLayout title=`${articlePrettyName} - 李守中`>
|
||||
<Nav />
|
||||
<ArticleBody collectionName="blog" articleSlug={entry.slug} />
|
||||
<Footer />
|
||||
</DefaultLayout>
|
||||
Reference in New Issue
Block a user