wip custom reference page
This commit is contained in:
8
packages/website/app/modules/api/api-data.server.ts
Normal file
8
packages/website/app/modules/api/api-data.server.ts
Normal 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
|
||||
}
|
||||
13
packages/website/app/modules/helpers/promise-all-object.ts
Normal file
13
packages/website/app/modules/helpers/promise-all-object.ts
Normal 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
|
||||
}
|
||||
@@ -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() }
|
||||
}
|
||||
Reference in New Issue
Block a user