Files
blitzkit/packages/website-ue/src/content.config.ts
T
2026-02-01 00:14:58 -06:00

43 lines
993 B
TypeScript

import { glob } from "astro/loaders";
import { z } from "astro/zod";
import { defineCollection } from "astro:content";
const api = defineCollection({
loader() {
const globbed = import.meta.glob("./pages/api/**/*.ts", {
eager: true,
query: "?raw",
import: "default",
});
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]
.replaceAll(/^ \* ?/gm, "");
if (!docs) continue;
paths.push({ id, docs });
}
return paths;
},
schema: z.object({
docs: z.optional(z.string()),
}),
});
const docs = defineCollection({
loader: glob({ base: "../../docs", pattern: "**/*.md" }),
});
export const collections = { api, docs };