mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-14 17:37:55 -05:00
* improvement(docs): overhaul docs * lint * light mode * more light mode * added llms.txt and llms-full.txt and sitemap * fixed mobile styling and position for zoom in out * finished styling * improvement(docs): overhaul docs * lint * remove dups * renaming components * cleanup
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import type { InferPageType } from 'fumadocs-core/source'
|
|
import { remarkInclude } from 'fumadocs-mdx/config'
|
|
import { remark } from 'remark'
|
|
import remarkGfm from 'remark-gfm'
|
|
import remarkMdx from 'remark-mdx'
|
|
import type { source } from '@/lib/source'
|
|
|
|
const processor = remark().use(remarkMdx).use(remarkInclude).use(remarkGfm)
|
|
|
|
export async function getLLMText(page: InferPageType<typeof source>) {
|
|
// Skip pages without proper file data
|
|
if (!page?.data?._file?.absolutePath || !page?.data?.content) {
|
|
return `# ${page.data.title || 'Untitled'}
|
|
URL: ${page.url || 'Unknown'}
|
|
|
|
${page.data.description || 'No description available'}`
|
|
}
|
|
|
|
try {
|
|
const processed = await processor.process({
|
|
path: page.data._file.absolutePath,
|
|
value: page.data.content,
|
|
})
|
|
|
|
return `# ${page.data.title || 'Untitled'}
|
|
URL: ${page.url || 'Unknown'}
|
|
|
|
${page.data.description || ''}
|
|
|
|
${processed.value}`
|
|
} catch (error) {
|
|
console.error(`Error processing page ${page.url}:`, error)
|
|
return `# ${page.data.title || 'Untitled'}
|
|
URL: ${page.url || 'Unknown'}
|
|
|
|
${page.data.description || 'No description available'}`
|
|
}
|
|
}
|