mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-27 09:19:53 +00:00
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
|
|
import { docsContentRoute, docsImageRoute, docsRoute } from './shared';
|
|
import { localMd } from '@fumadocs/local-md';
|
|
import { dynamicLoader } from 'fumadocs-core/source/dynamic';
|
|
|
|
const docs = localMd({
|
|
dir: 'content/docs',
|
|
});
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
void docs.devServer();
|
|
}
|
|
|
|
// See https://fumadocs.dev/docs/headless/source-api for more info
|
|
export const docsLoader = dynamicLoader(docs.dynamicSource(), {
|
|
baseUrl: docsRoute,
|
|
plugins: [lucideIconsPlugin()],
|
|
});
|
|
|
|
export async function getSource() {
|
|
return docsLoader.get();
|
|
}
|
|
|
|
export function getPageImage(page: (typeof docsLoader)['$inferPage']) {
|
|
const segments = [...page.slugs, 'image.png'];
|
|
|
|
return {
|
|
segments,
|
|
url: `${docsImageRoute}/${segments.join('/')}`,
|
|
};
|
|
}
|
|
|
|
export function getPageMarkdownUrl(page: (typeof docsLoader)['$inferPage']) {
|
|
const segments = [...page.slugs, 'content.md'];
|
|
|
|
return {
|
|
segments,
|
|
url: `${docsContentRoute}/${segments.join('/')}`,
|
|
};
|
|
}
|
|
|
|
export async function getLLMText(page: (typeof docsLoader)['$inferPage']) {
|
|
return `# ${page.data.title} (${page.url})
|
|
|
|
${page.data.content}`;
|
|
}
|