mirror of
https://github.com/Fission-AI/OpenSpec.git
synced 2026-10-30 07:53:11 +08:00
* docs(workflows): add lifecycle diagrams * docs(workflows): clarify optional archive paths * docs(workflows): correct lifecycle diagrams * docs(website): render Mermaid diagrams * fix(website): preserve Mermaid label text
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { docs } from 'collections/server';
|
|
import { renderPlaceholder } from 'fumadocs-core/mdx-plugins/remark-llms.runtime';
|
|
import { loader } from 'fumadocs-core/source';
|
|
import { icons } from 'lucide-react';
|
|
import { createElement } from 'react';
|
|
import { docsContentRoute, docsImageRoute, docsRoute } from './shared';
|
|
|
|
// See https://fumadocs.dev/docs/headless/source-api for more info
|
|
export const source = loader({
|
|
baseUrl: docsRoute,
|
|
source: docs.toFumadocsSource(),
|
|
// Render a lucide icon in the sidebar when a page sets `icon:` in frontmatter.
|
|
icon(icon) {
|
|
if (icon && icon in icons) {
|
|
return createElement(icons[icon as keyof typeof icons]);
|
|
}
|
|
},
|
|
plugins: [],
|
|
});
|
|
|
|
export function getPageImage(page: (typeof source)['$inferPage']) {
|
|
const segments = [...page.slugs, 'image.png'];
|
|
|
|
return {
|
|
segments,
|
|
url: `${docsImageRoute}/${segments.join('/')}`,
|
|
};
|
|
}
|
|
|
|
export function getPageMarkdownUrl(page: (typeof source)['$inferPage']) {
|
|
const segments = [...page.slugs, 'content.md'];
|
|
|
|
return {
|
|
segments,
|
|
url: `${docsContentRoute}/${segments.join('/')}`,
|
|
};
|
|
}
|
|
|
|
export async function getLLMText(page: (typeof source)['$inferPage']) {
|
|
const processed = await page.data.getText('processed');
|
|
const markdown = await renderPlaceholder(processed, {
|
|
Mermaid({ attributes }) {
|
|
if (typeof attributes.chart !== 'string') return '';
|
|
|
|
return `\`\`\`mermaid
|
|
${attributes.chart}
|
|
\`\`\``;
|
|
},
|
|
});
|
|
|
|
return `# ${page.data.title} (${page.url})
|
|
|
|
${markdown}`;
|
|
}
|