feat(docs): add MDX sandbox previews

This commit is contained in:
Maofeng
2026-09-21 17:09:44 +08:00
parent b26c8886cf
commit a9d6856ab8
8 changed files with 532 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import type { SandboxDefinition } from "./types"
type SandboxManifestModule = {
default: SandboxDefinition
}
const manifestModules = import.meta.glob<SandboxManifestModule>(
"../../sandboxes/*/*/sandbox.ts",
{ eager: true }
)
const sandboxDefinitions = new Map<string, SandboxDefinition>()
for (const module of Object.values(manifestModules)) {
const definition = module.default
if (sandboxDefinitions.has(definition.id)) {
throw new Error(`Duplicate sandbox id: ${definition.id}`)
}
sandboxDefinitions.set(definition.id, definition)
}
export function getSandboxDefinition(id: string) {
return sandboxDefinitions.get(id)
}