mirror of
https://github.com/nuxt/ui.git
synced 2026-09-14 19:51:10 +08:00
30 lines
930 B
TypeScript
30 lines
930 B
TypeScript
import type { H3Event } from 'h3'
|
|
import type { PageCollectionItemBase } from '@nuxt/content'
|
|
|
|
export default defineNitroPlugin((nitroApp) => {
|
|
nitroApp.hooks.hook('content:llms:generate:document', async (event: H3Event, doc: PageCollectionItemBase) => {
|
|
await transformMDC(event, doc as any)
|
|
})
|
|
|
|
nitroApp.hooks.hook('llms:generate', (_, { sections }) => {
|
|
sections.forEach((section) => {
|
|
if (section.title !== 'Documentation Sets') {
|
|
section.links = section.links.map(link => ({
|
|
...link,
|
|
href: transformRawLink(link.href)
|
|
}))
|
|
}
|
|
})
|
|
|
|
const docSetIdx = sections.findIndex(s => s.title === 'Documentation Sets')
|
|
if (docSetIdx !== -1) {
|
|
const [docSet] = sections.splice(docSetIdx, 1)
|
|
sections.push(docSet)
|
|
}
|
|
})
|
|
})
|
|
|
|
function transformRawLink(href: string) {
|
|
return `${href.replace(/^https:\/\/ui.nuxt.com/, 'https://ui.nuxt.com/raw')}.md`
|
|
}
|