Fortura/apps/www/lib/source.ts
2025-08-20 12:59:31 -06:00

41 lines
1.1 KiB
TypeScript

import { docs } from '@/.source';
import { loader } from 'fumadocs-core/source';
import { createElement, type ComponentType } from 'react';
import { icons } from 'lucide-react';
import { attachFile } from './attach-file';
import { attachSeparator } from './attach-separator';
// Loosen types to avoid strict coupling to fumadocs internal types at build time
type PageShape = {
data: {
body: ComponentType<any>;
toc?: unknown;
full?: boolean;
title: string;
description?: string;
author?: { name: string; url?: string } | undefined;
};
};
export const source = loader({
baseUrl: '/docs',
source: docs.toFumadocsSource(),
pageTree: {
attachFile,
attachSeparator,
},
icon(icon) {
if (!icon) {
return;
}
if (icon in icons) return createElement(icons[icon as keyof typeof icons]);
},
}) as unknown as {
getPage: (slug?: string[]) => PageShape | undefined;
// Minimal shape used by sitemap: url + file.path
getPages: () => Array<{ url: string; file: { path: string } }>;
generateParams: () => Promise<any> | any;
pageTree: unknown;
};