refactor
This commit is contained in:
parent
846bce9480
commit
60aea94006
32 changed files with 328 additions and 278 deletions
33
src/pages/[category]/[slug].astro
Normal file
33
src/pages/[category]/[slug].astro
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import PostLayout from "../../layouts/PostLayout.astro";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const CATS = ["algorithms", "software", "meditations", "autonomous-racing"];
|
||||
|
||||
const entries = [];
|
||||
for (const c of CATS) {
|
||||
const docs = await getCollection(c);
|
||||
for (const d of docs) {
|
||||
entries.push({
|
||||
params: { category: c, slug: d.slug },
|
||||
props: { post: d },
|
||||
});
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
const category = Astro.params.category;
|
||||
const pageTitle = `${category}/${post.data.title ?? post.slug}`;
|
||||
const { Content } = await post.render();
|
||||
---
|
||||
|
||||
<PostLayout frontmatter={post.data}>
|
||||
<Fragment slot="head">
|
||||
<title>{pageTitle}</title>
|
||||
<script type="module" src="/scripts/index.js"></script>
|
||||
</Fragment>
|
||||
<Content />
|
||||
</PostLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue