mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-05 04:07:36 +08:00
- Updated the demo API to support locale-based content rendering. - Refactored the main layout to accommodate language-specific metadata and routing. - Introduced new components for blog and documentation pages, ensuring proper language handling. - Added styles for improved UI consistency across different sections. - Removed deprecated layout files and streamlined the structure for better maintainability.
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import { loader } from 'fumadocs-core/source';
|
|
import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
|
|
import { docsContentRoute, docsImageRoute, docsRoute } from './shared';
|
|
import { defineDocs } from 'fumadocs-mdx/macro';
|
|
import { metaSchema, pageSchema } from 'fumadocs-core/source/schema';
|
|
import { i18n } from './i18n';
|
|
|
|
const docs = defineDocs({
|
|
dir: 'content/docs',
|
|
docs: {
|
|
schema: pageSchema,
|
|
postprocess: {
|
|
includeProcessedMarkdown: true,
|
|
},
|
|
},
|
|
meta: {
|
|
schema: metaSchema,
|
|
},
|
|
});
|
|
|
|
// See https://fumadocs.dev/docs/headless/source-api for more info
|
|
export const source = loader({
|
|
baseUrl: docsRoute,
|
|
source: docs.toFumadocsSource(),
|
|
plugins: [lucideIconsPlugin()],
|
|
i18n,
|
|
});
|
|
|
|
/** Locale URL prefix segment; empty for the default (hidden) locale. */
|
|
function localeSegment(page: (typeof source)['$inferPage']): string | undefined {
|
|
return page.locale === i18n.defaultLanguage ? undefined : page.locale;
|
|
}
|
|
|
|
export function getPageImageUrl(page: (typeof source)['$inferPage']) {
|
|
const segments = [...page.slugs, 'image.png'];
|
|
|
|
return {
|
|
segments,
|
|
url:
|
|
'/' +
|
|
[localeSegment(page), ...docsImageRoute.split('/'), ...segments].filter(Boolean).join('/'),
|
|
};
|
|
}
|
|
|
|
export function getPageMarkdownUrl(page: (typeof source)['$inferPage']) {
|
|
const segments = [...page.slugs, 'content.md'];
|
|
|
|
return {
|
|
segments,
|
|
url:
|
|
'/' +
|
|
[localeSegment(page), ...docsContentRoute.split('/'), ...segments].filter(Boolean).join('/'),
|
|
};
|
|
}
|
|
|
|
export async function getLLMText(page: (typeof source)['$inferPage']) {
|
|
const processed = await page.data.getText('processed');
|
|
|
|
return `# ${page.data.title} (${page.url})
|
|
|
|
${processed}`;
|
|
}
|