26 lines
484 B
TypeScript
26 lines
484 B
TypeScript
import type { ComponentType } from "react";
|
|
|
|
const modules = import.meta.glob("../docs/**/*.tsx", {
|
|
eager: true,
|
|
});
|
|
|
|
type DocModule = {
|
|
default: ComponentType;
|
|
};
|
|
|
|
const docsMap: Record<string, ComponentType> = {};
|
|
|
|
for (const path in modules) {
|
|
const mod = modules[path] as DocModule;
|
|
|
|
const slug = path
|
|
.replace("../docs/", "")
|
|
.replace(".tsx", "");
|
|
|
|
// "notifications/intro"
|
|
docsMap[slug] = mod.default;
|
|
}
|
|
|
|
export function getDoc(slug: string) {
|
|
return docsMap[slug];
|
|
} |