From c403a8151b87654a0cb24ad28fb23edc3f78906e Mon Sep 17 00:00:00 2001 From: Skyler Grey Date: Sat, 25 May 2024 15:11:07 +0000 Subject: [PATCH] chore: format [...slug].astro --- src/pages/[...slug].astro | 149 +++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 84 deletions(-) diff --git a/src/pages/[...slug].astro b/src/pages/[...slug].astro index 5c0ee7c..9dd5234 100644 --- a/src/pages/[...slug].astro +++ b/src/pages/[...slug].astro @@ -1,102 +1,83 @@ --- -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 paths = allPageAndDirectoryPaths(wikiPages); - return [ - { - params: { slug: undefined }, - props: { path: "home", name: "Home", post: await getEntry("wiki", "home") } - }, - ...Array.from(paths.entries()).flatMap(([key, post]) => { - if (!post) { - return [{ - params: { slug: key }, - props: { path: key, name: parse(key).name } - }] - } 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 }, - } - ] - } - }) - - // ...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 }, - // } - // ] - // } - // }) - ]; + const wikiPages = await getCollection("wiki"); + const paths = allPageAndDirectoryPaths(wikiPages); + return [ + { + params: { slug: undefined }, + props: { + path: "home", + name: "Home", + post: await getEntry("wiki", "home"), + }, + }, + ...Array.from(paths.entries()).flatMap(([key, post]) => { + if (!post) { + return [ + { + params: { slug: key }, + props: { path: key, name: parse(key).name }, + }, + ]; + } 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'> - path: string; - name: string; + post?: CollectionEntry<"wiki">; + path: string; + name: string; }; const { post, path, name } = Astro.props; --- - - Aux Docs - {name} - { - post ? ( - - ) : null - } + + Aux Docs - {name} + { + post ? ( + + ) : null + } - - { - post ? ( - - ) : ( - - ) - } + + {post ? : }