chore: format [...slug].astro
This commit is contained in:
parent
dd452009fe
commit
c403a8151b
|
@ -1,26 +1,32 @@
|
|||
---
|
||||
import { type CollectionEntry, getCollection, getEntry } from 'astro:content';
|
||||
import NavBar from '../components/NavBar.astro';
|
||||
import Renderer from '../components/Renderer.astro';
|
||||
import NavPage from '../components/NavPage.astro';
|
||||
import "../style/globals.css"
|
||||
import { type CollectionEntry, getCollection, getEntry } from "astro:content";
|
||||
import NavBar from "../components/NavBar.astro";
|
||||
import Renderer from "../components/Renderer.astro";
|
||||
import NavPage from "../components/NavPage.astro";
|
||||
import "../style/globals.css";
|
||||
import { allPageAndDirectoryPaths } from "../lib/pagePaths";
|
||||
import { parse } from "node:path"
|
||||
import { parse } from "node:path";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const wikiPages = await getCollection('wiki');
|
||||
const wikiPages = await getCollection("wiki");
|
||||
const paths = allPageAndDirectoryPaths(wikiPages);
|
||||
return [
|
||||
{
|
||||
params: { slug: undefined },
|
||||
props: { path: "home", name: "Home", post: await getEntry("wiki", "home") }
|
||||
props: {
|
||||
path: "home",
|
||||
name: "Home",
|
||||
post: await getEntry("wiki", "home"),
|
||||
},
|
||||
},
|
||||
...Array.from(paths.entries()).flatMap(([key, post]) => {
|
||||
if (!post) {
|
||||
return [{
|
||||
return [
|
||||
{
|
||||
params: { slug: key },
|
||||
props: { path: key, name: parse(key).name }
|
||||
}]
|
||||
props: { path: key, name: parse(key).name },
|
||||
},
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
{
|
||||
|
@ -30,34 +36,15 @@ export async function getStaticPaths() {
|
|||
{
|
||||
params: { slug: post.slug + ".md" },
|
||||
props: { path: post.id, name: post.data.title, post },
|
||||
},
|
||||
];
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// ...pages.flatMap((post: CollectionEntry<'wiki'> | undefined) => {
|
||||
// if (!post) {
|
||||
// return [{
|
||||
// params: { slug: }
|
||||
// }]
|
||||
// } else {
|
||||
// return [
|
||||
// {
|
||||
// params: { slug: post.slug },
|
||||
// props: { path: post.id, name: post.data.title, post },
|
||||
// },
|
||||
// {
|
||||
// params: { slug: post.slug + ".md" },
|
||||
// props: { path: post.id, name: post.data.title, post },
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// })
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
type Props = {
|
||||
post?: CollectionEntry<'wiki'>
|
||||
post?: CollectionEntry<"wiki">;
|
||||
path: string;
|
||||
name: string;
|
||||
};
|
||||
|
@ -66,7 +53,7 @@ const { post, path, name } = Astro.props;
|
|||
---
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title>Aux Docs - {name}</title>
|
||||
{
|
||||
post ? (
|
||||
|
@ -92,11 +79,5 @@ const { post, path, name } = Astro.props;
|
|||
<div class="nav-pane">
|
||||
<NavBar currentPage={path} />
|
||||
</div>
|
||||
{
|
||||
post ? (
|
||||
<Renderer post={post} />
|
||||
) : (
|
||||
<NavPage path={path} />
|
||||
)
|
||||
}
|
||||
{post ? <Renderer post={post} /> : <NavPage path={path} />}
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue