diff --git a/packages/website-ue/src/content.config.ts b/packages/website-ue/src/content.config.ts index 6e1f56319..095421cdf 100644 --- a/packages/website-ue/src/content.config.ts +++ b/packages/website-ue/src/content.config.ts @@ -10,29 +10,27 @@ const api = defineCollection({ import: "default", }); - const paths: { id: string; body: string }[] = []; + const paths: { id: string; docs: string }[] = []; for (const path in globbed) { const id = path.replace("./pages/api/", "").replace(".ts", ""); + const body = (globbed[path] as string).replaceAll("\r\n", "\n"); const docs = body .match( /\/\*\*\n((( \*.*)\n)+) \*\/\nexport (async )?function GET\(/, )?.[1] - .split("\n") - .map((line) => line.replace(/ \* ?/, "")) - .join("\n"); + .replaceAll(/^ \* ?/gm, ""); if (!docs) continue; - paths.push({ id, body: docs }); + paths.push({ id, docs }); } return paths; }, schema: z.object({ - body: z.string(), docs: z.optional(z.string()), }), }); diff --git a/packages/website-ue/src/pages/[...locale]/api/index.astro b/packages/website-ue/src/pages/[...locale]/api/index.astro index f426dfbae..6eadb32df 100644 --- a/packages/website-ue/src/pages/[...locale]/api/index.astro +++ b/packages/website-ue/src/pages/[...locale]/api/index.astro @@ -1,7 +1,6 @@ --- import "@radix-ui/colors/amber-dark.css"; import { getCollection } from "astro:content"; -import { tools } from "../../../core/tools/tools"; import BaseLayout from "../../../layouts/BaseLayout.astro"; export { getStaticPaths } from "../index.astro"; @@ -9,8 +8,6 @@ export { getStaticPaths } from "../index.astro"; const { locale } = Astro.props; const collection = await getCollection("api"); -console.log(collection); - const paths: { path: string; documentation: string; @@ -19,15 +16,14 @@ const paths: { paths.sort((a, b) => a.path.localeCompare(b.path)); --- - +

api

{ collection.map(({ id, data }) => ( <>

{id}

-
{data.docs}
-
{data.body}
+
{data.docs}
)) } diff --git a/packages/website-ue/src/pages/api/tanks/[id].json.ts b/packages/website-ue/src/pages/api/tanks/[id].json.ts index fc8843c73..326f97c49 100644 --- a/packages/website-ue/src/pages/api/tanks/[id].json.ts +++ b/packages/website-ue/src/pages/api/tanks/[id].json.ts @@ -4,6 +4,9 @@ import { api } from "../../../core/api/dynamic"; export { getStaticPaths } from "./[id].pb"; /** + * Even Noah can't save these animals. + * Even Noah can't save these animals. + * Even Noah can't save these animals. * Even Noah can't save these animals. */ export async function GET({ params }: APIContext) {