wip custom reference page

This commit is contained in:
MapleLeaf
2022-01-14 01:01:28 -06:00
parent 05bda71ad6
commit 723d663d3c
9 changed files with 276 additions and 93 deletions

View File

@@ -0,0 +1,8 @@
import type { JSONOutput } from "typedoc"
export type ApiData = JSONOutput.ContainerReflection
export async function loadApiData(): Promise<ApiData> {
const data = await import("~/assets/api.json")
return data as ApiData
}

View File

@@ -0,0 +1,13 @@
export async function promiseAllObject<Input extends object>(
input: Input,
): Promise<{
[K in keyof Input]: Awaited<Input[K]>
}> {
const result: any = {}
await Promise.all(
Object.entries(input).map(async ([key, promise]) => {
result[key] = await promise
}),
)
return result
}

View File

@@ -0,0 +1,23 @@
export async function renderMarkdown(
markdown: string,
): Promise<{ __html: string }> {
const rehypePrism = import("rehype-prism-plus").then(
(module) => module.default,
)
const rehypeStringify = import("rehype-stringify").then(
(module) => module.default,
)
const remarkParse = import("remark-parse").then((module) => module.default)
const remarkRehype = import("remark-rehype").then((module) => module.default)
const { unified } = await import("unified")
const processor = unified()
.use(await remarkParse)
.use(await remarkRehype)
.use(await rehypeStringify)
.use(await rehypePrism)
const result = await processor.process(markdown)
return { __html: result.toString() }
}