'ai-ready:llms-txt'Type: (payload: { sections: LlmsTxtSection[], notes: string[] }) => void | Promise<void>
Called before llms.txt generation. Modify or add sections and notes to customize the output.
Payload:
sections - Array of sections with title, description, and links (modify directly)notes - Array of note strings to appear at the end (modify directly)export default defineNuxtConfig({
hooks: {
'ai-ready:llms-txt': async (payload) => {
// Add custom section
payload.sections.push({
title: 'Custom APIs',
description: 'Additional endpoints',
links: [
{ title: 'Custom Endpoint', href: '/api/custom', description: 'Custom API' }
]
})
// Add note
payload.notes.push('Built with Nuxt AI Ready')
}
}
})
sections and notes arrays directly rather than returning values.'ai-ready:routes'Type: (payload: { routes: Record<string, string> }) => void | Promise<void>
Registers AI-ready API routes from other modules. Routes will be included in llms.txt and documentation.
Payload:
routes - Record of route names to URLs (modify directly)export default defineNuxtConfig({
hooks: {
'ai-ready:routes': async (payload) => {
// Register custom API endpoint
payload.routes['Custom Search'] = '/api/custom-search'
}
}
})
'ai-ready:chunk'Type: (context: ChunkContext) => void | Promise<void>
Called during build for each generated chunk during prerendering. Implement RAG tooling such as vector embeddings and search indexing.
Context:
chunk - The chunk data (BulkChunk with id, route, content)route - Page route (e.g., '/about')title - Page titledescription - Meta descriptionheadings - Extracted headings array (e.g., [{ h1: 'Title' }, { h2: 'Subtitle' }])export default defineNuxtConfig({
hooks: {
'ai-ready:chunk': async (context) => {
// Generate embeddings for each chunk
const embedding = await generateEmbedding(context.chunk.content)
// Store in vector database
// Chunk index can be inferred from id suffix (e.g., "abc123-0", "abc123-1")
const chunkIndex = Number.parseInt(context.chunk.id.split('-').pop() || '0')
await vectorDb.insert({
id: context.chunk.id,
vector: embedding,
metadata: {
route: context.route,
title: context.title,
chunkIndex,
}
})
}
}
})