### Notes Section Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Provides an example of how to structure the `notes` array with various types of information. ```typescript notes: [ 'Version 2.3.0 (released 2025-06-20)', `Generated ${new Date().toISOString()}`, 'All API endpoints are rate-limited to 1000 requests/hour', 'See https://example.com/status for incidents' ] ``` -------------------------------- ### Setup Function Parameters Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Describes the parameters accepted by the module's setup function. ```typescript setup(options: ModuleOptions, nuxt: Nuxt): void ``` -------------------------------- ### Advanced Example: Multi-section Documentation Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md Demonstrates how to add multiple distinct sections to the generated content using onLLMsGenerateFull, covering getting started, advanced usage, and error handling. ```typescript // server/plugins/llms-guides.ts export default defineNitroPlugin((nitroApp) => { onLLMsGenerateFull((event, options, contents) => { // Section 1: Getting Started contents.push(`## Getting Started ### Installation \ npm install @myapp/sdk \ ### Quick Example \ import { Client } from '@myapp/sdk' const client = new Client({ apiKey: process.env.API_KEY }) const result = await client.users.list() console.log(result) \ `) // Section 2: Advanced Usage contents.push(`## Advanced Usage ### Custom Middleware \ client.use((req, next) => { req.headers['X-Custom-Header'] = 'value' return next() }) \ `) // Section 3: Error Handling contents.push(`## Error Handling Try-catch pattern: \ try { const user = await client.users.get('user_123') } catch (error) { console.error(error.code, error.message) } \ `) }) }) ``` -------------------------------- ### Registration Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Example of how the route handler is registered during module setup. ```typescript // In module.ts if (options.domain) { addServerHandler({ route: '/llms.txt', handler: resolve('./runtime/server/routes/llms.txt.get'), }) addPrerenderRoutes('/llms.txt') } ``` -------------------------------- ### Install the module Source: https://github.com/nuxt-content/nuxt-llms/blob/main/README.md Install the nuxt-llms module using npm. ```bash npm i nuxt-llms ``` -------------------------------- ### Custom Documentation Module Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Example of a custom server plugin that adds custom documentation content using the 'llms:generate:full' hook. ```typescript // server/plugins/add-custom-docs.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { contents.push(`## Custom Documentation Your custom content here... Base URL: ${options.domain} `) }) }) ``` -------------------------------- ### Complete Configuration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md A comprehensive configuration example including domain, title, description, sections, notes, and full documentation endpoint. ```typescript // nuxt.config.ts export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { domain: 'https://example.com', title: 'My SaaS Platform', description: 'A comprehensive platform for managing workflows and data', sections: [ { title: 'Getting Started', description: 'Start using the platform with these resources', links: [ { title: 'Installation Guide', description: 'Step-by-step setup instructions', href: 'https://example.com/docs/install' }, { title: 'Quick Start', description: 'Get up and running in 5 minutes', href: 'https://example.com/docs/quick-start' } ] }, { title: 'API Reference', description: 'Complete API documentation', links: [ { title: 'REST API', href: 'https://example.com/api/rest' }, { title: 'GraphQL', href: 'https://example.com/api/graphql' } ] } ], notes: [ 'Documentation auto-generated on 2025-06-27', 'API endpoints subject to rate limits', 'See https://example.com/status for service status' ], full: { title: 'Extended Documentation', description: 'Detailed guides, tutorials, and API documentation' } } }) ``` -------------------------------- ### Usage Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Provides an example of how to configure the nuxt-llms module in nuxt.config.ts. ```typescript // nuxt.config.ts export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { domain: 'https://example.com', title: 'My Application', description: 'Application documentation', sections: [ { title: 'Documentation', links: [ { title: 'Getting Started', href: 'https://example.com/docs' } ] } ], full: { title: 'Full Documentation', description: 'Extended documentation' } } }) ``` -------------------------------- ### GET /llms.txt Example Response Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Example response for the GET /llms.txt endpoint, showing structured markdown documentation. ```text # My Application > Application description ## Getting Started Start here - [Quick Start Guide](https://example.com/quick-start): Quick setup - [Full Docs](https://example.com/docs) ## Notes - Documentation updated 2025-06-27 ``` -------------------------------- ### Validation Example - Missing Domain Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md An example configuration that will trigger a warning due to the missing required `domain` property, preventing endpoint generation. ```typescript // This will warn and not generate endpoints export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { // Missing required 'domain' title: 'My App' } }) ``` -------------------------------- ### Example llms.txt Response Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/endpoints.md Example Response: ```markdown # My Application > A comprehensive documentation of my application ## Getting Started Start using our application with these resources. - [Quick Start Guide](https://example.com/docs): Complete setup instructions - [API Reference](https://example.com/api): Detailed API documentation ## Support Get help and support from our community. - [FAQ](https://example.com/faq) - [Community Forum](https://example.com/community): Join our discussion forum ## Notes - This documentation is automatically generated - Last updated: 2025-06-27 ``` -------------------------------- ### Example Usage for llms:generate:full hook Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/endpoints.md Example Usage: ```typescript // server/plugins/llms.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { contents.push(`## API Documentation ### Authentication Use Bearer tokens in the Authorization header. ### Endpoints - GET /api/users - POST /api/data `) }) }) ``` -------------------------------- ### Nuxt Content Integration Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Shows how Nuxt Content automatically registers a hook to contribute published content to the full documentation. ```typescript // @nuxt/content automatically contributes nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { // Adds all published content files to full documentation }) ``` -------------------------------- ### Migration Guide: Before (Deprecated) Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-hooks.md Example of using the deprecated `llmsHooks` system before migration. ```typescript // server/plugins/old-hooks.ts import { llmsHooks } from 'nuxt-llms/runtime' llmsHooks.hook('generate', (event, options) => { options.sections.push({ title: 'API', links: [{ title: 'Docs', href: 'https://example.com/api' }] }) }) llmsHooks.hook('generate:full', (event, options, contents) => { contents.push('## Full API Documentation\n\nDetails...') }) ``` -------------------------------- ### Migration Guide: After (Recommended) Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-hooks.md Example of migrating to the recommended Nitro hooks system. ```typescript // server/plugins/new-hooks.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate', (event, options) => { options.sections.push({ title: 'API', links: [{ title: 'Docs', href: 'https://example.com/api' }] }) }) nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { contents.push('## Full API Documentation\n\nDetails...') }) }) ``` -------------------------------- ### Usage Example for onLLMsGenerate Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md Example of how to use onLLMsGenerate to dynamically add a new section and modify existing configuration. ```typescript // server/plugins/llms-extend.ts export default defineNitroPlugin((nitroApp) => { onLLMsGenerate((event, options) => { // Add a new section dynamically options.sections.push({ title: 'API Documentation', description: 'REST API endpoints', links: [ { title: 'User Endpoints', description: 'User management API', href: `${options.domain}/api/users` }, { title: 'Data Endpoints', description: 'Data storage API', href: `${options.domain}/api/data` } ] }) // Modify existing configuration options.notes = options.notes || [] options.notes.push('API endpoints are rate-limited') }) }) ``` -------------------------------- ### Environment-Specific Configuration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Example of using environment variables for environment-specific configuration of Nuxt LLMs. ```typescript // nuxt.config.ts export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { domain: process.env.NUXT_PUBLIC_DOMAIN || 'https://example.com', title: process.env.NUXT_APP_NAME || 'My Application', description: `Version: ${process.env.npm_package_version}`, } }) ``` -------------------------------- ### With Nuxt Content Integration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Example of configuring Nuxt LLMs alongside Nuxt Content. Nuxt Content automatically contributes via hooks. ```typescript // nuxt.config.ts export default defineNuxtConfig({ modules: ['nuxt-llms', '@nuxt/content'], llms: { domain: 'https://example.com', title: 'My Documentation Site', description: 'Content-driven documentation with LLM support', // Nuxt Content automatically contributes via hooks } }) ``` -------------------------------- ### Configuration Handling - Module Setup Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Sets configuration in runtimeConfig during module setup. ```typescript // In module.ts nuxt.options.runtimeConfig.llms = { domain: options.domain, title: options.title, description: options.description, notes: options.notes || [], sections: options.sections || [] } ``` -------------------------------- ### Usage Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md Example of using onLLMsGenerateFull to add API documentation, rate limiting, and webhook information to the generated content. ```typescript // server/plugins/llms-full-content.ts export default defineNitroPlugin((nitroApp) => { onLLMsGenerateFull((event, options, contents) => { // Add detailed API documentation contents.push(`## API Documentation ### Authentication All API endpoints require authentication via Bearer token: \ Authorization: Bearer \ \ ### Rate Limiting - Standard tier: 1,000 requests/hour - Premium tier: 10,000 requests/hour - Enterprise: Unlimited ### Base URL \ ${options.domain}/api/v1 \ `) // Add another section contents.push(`## Webhooks Subscribe to events in your application. ### Available Events - \`user.created. \ - \`user.updated. \ - \`data.processed. \ ### Example Payload \ { "event": "user.created", "timestamp": "2025-06-27T10:30:00Z", "data": { "id": "user_123", "email": "user@example.com" } } \ `) }) }) ``` -------------------------------- ### Link Href Patterns - Dynamic Values Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Example of using template literals to reference the `options.domain` for dynamic href values in links. ```typescript href: `${options.domain}/api/docs` ``` -------------------------------- ### Configuration Validation Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Demonstrates the validation check for the required 'domain' option. ```typescript if (!options.domain) { logger.warn('nuxt-llms require a domain to be set. `llms.domain` is missing.') return } ``` -------------------------------- ### Content Contribution Pattern Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Example of how a hook handler contributes markdown content to the documentation. ```typescript export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { // Contribute a documentation section contents.push(`## API Documentation ### Authentication All requests require a Bearer token in the Authorization header. \ Authorization: Bearer \ \ ### Rate Limits - Standard: 1000 requests/hour - Premium: 10000 requests/hour `) }) }) ``` -------------------------------- ### Multiple Hook Handlers Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Demonstrates how multiple server plugins can register handlers for the 'llms:generate:full' hook to contribute to the same endpoint. ```typescript // server/plugins/api-docs.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { contents.push(`## REST API\n\n...`) }) }) // server/plugins/guides.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { contents.push(`## Getting Started\n\n...`) }) }) ``` -------------------------------- ### `llms:generate:full` Hook Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Example of how to use the `llms:generate:full` hook to contribute extended documentation content. ```typescript nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { contents.push('## New Content\n\n...') }) ``` -------------------------------- ### Nuxt Configuration for Full LLM Endpoint Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Example of enabling the full LLM endpoint by configuring 'llms.full' in nuxt.config.ts. ```typescript export default defineNuxtConfig({ llms: { domain: 'https://example.com', title: 'My Application', full: { title: 'Full Documentation', description: 'Extended documentation with guides and API reference' } } }) ``` -------------------------------- ### Using Hooks in Nuxt Modules Source: https://github.com/nuxt-content/nuxt-llms/blob/main/README.md Example of how a Nuxt module can extend LLMs documentation by registering a server plugin. ```typescript // module/runtime/server/plugins/my-module-llms.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate', (event, options) => { options.sections.push({ title: 'My Module', description: 'Documentation for my module features', links: [/* ... */] }) }) }) ``` ```typescript import { defineNuxtModule, addServerPlugin } from '@nuxt/kit' import { fileURLToPath } from 'url' export default defineNuxtModule({ setup(options, nuxt) { const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url)) addServerPlugin(resolve(runtimeDir, 'server/plugins/my-module-llms')) } }) ``` -------------------------------- ### Complete Nuxt Configuration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Complete configuration example for the nuxt-llms module, including domain, title, description, sections, notes, and full documentation options. ```typescript export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { domain: 'https://example.com', title: 'My Application', description: 'Application description', sections: [ { title: 'Getting Started', description: 'Start here', links: [ { title: 'Docs', description: 'Documentation link', href: 'https://example.com/docs' } ] } ], notes: ['Note 1', 'Note 2'], full: { title: 'Full Documentation', description: 'Extended docs' } } }) ``` -------------------------------- ### Prerendering Route Registration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Example of how the /llms-full.txt route is automatically added to Nuxt's prerender list. ```typescript addPrerenderRoutes('/llms-full.txt') ``` -------------------------------- ### Runtime Configuration Access Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Example of accessing and modifying Nuxt LLMs configuration within a Nitro plugin. ```typescript // server/plugins/llms-plugin.ts export default defineNitroPlugin((nitroApp) => { // Access current configuration during hook execution nitroApp.hooks.hook('llms:generate', (event, options) => { console.log(options.domain) console.log(options.title) // Modify options to extend documentation }) }) ``` -------------------------------- ### `llms:generate` Hook Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Example of how to use the `llms:generate` hook to modify structured documentation by pushing a new section. ```typescript nitroApp.hooks.hook('llms:generate', (event, options) => { options.sections.push({ /* new section */ }) }) ``` -------------------------------- ### Route Handler Registration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Example of registering the '/llms-full.txt' route handler and configuring it within the Nuxt module. ```typescript // In module.ts if (options.full) { // Add "Documentation Sets" section to llms.txt config llmsConfig.sections.unshift({ title: 'Documentation Sets', links: [ { title: options.full.title, description: options.full.description, href: `${options.domain}/llms-full.txt`, }, ], }) // Register the route handler addServerHandler({ route: '/llms-full.txt', handler: resolve('./runtime/server/routes/llms-full.txt.get'), }) // Add to prerender routes addPrerenderRoutes('/llms-full.txt') } ``` -------------------------------- ### Nuxt Content Integration Configuration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/README.md Example Nuxt configuration for integrating Nuxt LLMs with Nuxt Content. ```javascript export default defineNuxtConfig({ modules: ['nuxt-llms', '@nuxt/content'], llms: { domain: 'https://example.com', title: 'My Application', description: 'My Application Description', }, }) ``` -------------------------------- ### Hook Modification Example Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Example of modifying the LLM generation options using a Nitro plugin hook. ```typescript // server/plugins/extend-docs.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate', (event, options) => { // Add sections dynamically options.sections.push({ title: 'Extra Section', links: [{ title: 'Link', href: 'https://example.com' }] }) // Modify title options.title = `${options.title} - Extended` // Add notes options.notes = options.notes || [] options.notes.push('Generated dynamically') }) }) ``` -------------------------------- ### Using Hooks in Your Application Source: https://github.com/nuxt-content/nuxt-llms/blob/main/README.md Example of how to use Nuxt LLMs hooks directly in a server plugin to modify documentation content. ```typescript export default defineNitroPlugin((nitroApp) => { // Method 1: Using the hooks directly nitroApp.hooks.hook('llms:generate', (event, options) => { // Add a new section to llms.txt options.sections.push({ title: 'API Documentation', description: 'REST API endpoints and usage', links: [ { title: 'Authentication', description: 'API authentication methods', href: `${options.domain}/api/auth` } ] }) }) // Method 2: Using the helper function nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { // Add detailed documentation to llms-full.txt contents.push(`## API Authentication ### Bearer Token To authenticate API requests, include a Bearer token in the Authorization header: \ Authorization: Bearer \ ### API Keys For server-to-server communication, use API keys: \ X-API-Key: \ `) }) }) ``` -------------------------------- ### Module Definition Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Defines the Nuxt module with its metadata, default options, and setup function. ```typescript export default defineNuxtModule({ meta: { name: 'nuxt-llms', configKey: 'llms', version: string, docs: 'https://github.com/nuxtlabs/nuxt-llms', }, defaults: {}, setup(options: ModuleOptions, nuxt: Nuxt): void }) ``` -------------------------------- ### Contribute Full Documentation via Server Plugin Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Example of contributing full documentation content using the `llms:generate:full` hook within a server plugin. ```typescript // server/plugins/full-docs.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { contents.push(`## API Documentation Base URL: ${options.domain}/api/v1 ### Authentication Use Bearer tokens... `) }) }) ``` -------------------------------- ### Extend Documentation within a Nuxt Module Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Example demonstrating how to extend documentation hooks when creating a Nuxt module. ```typescript // my-module/index.ts import { defineNuxtModule, addServerPlugin } from '@nuxt/kit' export default defineNuxtModule({ setup(options, nuxt) { addServerPlugin('./runtime/server/plugins/llms-extend') } }) // my-module/runtime/server/plugins/llms-extend.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate', (event, options) => { // Extend documentation }) }) ``` -------------------------------- ### Advanced Example: Conditional Content with onLLMsGenerate Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md Demonstrates conditional content generation based on environment variables or request headers. ```typescript // server/plugins/llms-conditional.ts export default defineNitroPlugin((nitroApp) => { onLLMsGenerate((event, options) => { // Check environment or feature flags if (process.env.NODE_ENV === 'production') { options.sections.push({ title: 'Status Page', links: [ { title: 'Service Status', href: 'https://status.example.com' } ] }) } // Check request headers const userAgent = event.node.req.headers['user-agent'] || '' if (userAgent.includes('bot')) { options.notes?.push('This documentation is optimized for AI consumption') } }) }) ``` -------------------------------- ### Usage in Modules Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md Example of how to use Nuxt LLMs hooks within a Nuxt module to extend its functionality. ```typescript // my-module/runtime/server/plugins/llms-extend.ts import { onLLMsGenerate, onLLMsGenerateFull } from 'nuxt-llms/runtime' export default defineNitroPlugin(() => { onLLMsGenerate((event, options) => { options.sections.push({ title: 'My Module', description: 'Features from my module', links: [ { title: 'Docs', href: 'https://example.com/my-module' } ] }) }) onLLMsGenerateFull((event, options, contents) => { contents.push(`## My Module Documentation\n\nDetailed info...`) }) }) ``` ```typescript // my-module/index.ts import { defineNuxtModule, addServerPlugin, createResolver } from '@nuxt/kit' export default defineNuxtModule({ setup(options, nuxt) { const { resolve } = createResolver(import.meta.url) addServerPlugin(resolve('./runtime/server/plugins/llms-extend')) } }) ``` -------------------------------- ### Extend Structured Documentation via Server Plugin Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Example of extending structured documentation using the `llms:generate` hook within a server plugin. ```typescript // server/plugins/extend-llms.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate', (event, options) => { options.sections.push({ title: 'API', links: [{ title: 'REST API', href: 'https://example.com/api' }] }) }) }) ``` -------------------------------- ### Recommended Alternative: Nitro Hooks Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-hooks.md Example of how to use the standard Nitro hook system to extend LLM generation functionality. ```typescript // server/plugins/llms-extend.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate', (event, options) => { // Extend /llms.txt documentation }) nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { // Extend /llms-full.txt documentation }) }) ``` -------------------------------- ### Minimal Configuration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Generates `/llms.txt` with minimal content. Title defaults to "Documentation". ```typescript // nuxt.config.ts export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { domain: 'https://example.com' } }) ``` -------------------------------- ### Module Registration with Inline Options Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Demonstrates registering the `nuxt-llms` module with inline configuration options. ```typescript export default defineNuxtConfig({ modules: [ ['nuxt-llms', { domain: 'https://example.com' }] ] }) ``` -------------------------------- ### Module Registration with Separate Config Key Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Illustrates the recommended approach of registering the module and using a separate `llms` config key for options. ```typescript export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { /* options */ } }) ``` -------------------------------- ### Module Registration with Defaults Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Shows how to register the `nuxt-llms` module with default options. ```typescript export default defineNuxtConfig({ modules: [ 'nuxt-llms' // With defaults ] }) ``` -------------------------------- ### Dynamic Sections via Hooks Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/configuration.md Demonstrates how to dynamically add sections to the LLM configuration at runtime using Nitro plugins and hooks. ```typescript // server/plugins/dynamic-sections.ts export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate', (event, options) => { // Add sections based on environment or feature flags if (process.env.SHOW_ENTERPRISE_DOCS === 'true') { options.sections.push({ title: 'Enterprise Features', description: 'Advanced features for enterprise customers', links: [ { title: 'SSO Configuration', href: 'https://example.com/docs/sso' }, { title: 'Advanced Analytics', href: 'https://example.com/docs/analytics' } ] }) } }) }) ``` -------------------------------- ### Multiple Content Pushes in One Handler Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Demonstrates how to push multiple content sections to the 'llms:generate:full' hook. ```typescript // Example: Multiple content pushes in one handler nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { contents.push(`## Getting Started\n\n...`) contents.push(`## Configuration\n\n...`) contents.push(`## Examples\n\n...`) }) ``` -------------------------------- ### Server Imports Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Demonstrates how `llmsHooks` are automatically available in server plugins without explicit import. ```typescript // Available in server plugins without explicit import // server/plugins/my-plugin.ts export default defineNitroPlugin(() => { // llmsHooks is automatically available }) ``` -------------------------------- ### Content Formatting Guidelines Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md Illustrates the expected markdown formatting for content sections pushed to the contents array, including titles, subsections, paragraphs, code blocks, lists, and tables. ```typescript contents.push(`## Section Title ### Subsection Content paragraph with **bold** and *italic*. \ // Code blocks with language highlighting const example = true \ - Bullet list item 1 - Bullet list item 2 | Column 1 | Column 2 | |----------|----------| | Cell 1 | Cell 2 | `) ``` -------------------------------- ### Runtime Config Initialization Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Illustrates how the module stores processed options in the Nuxt runtime configuration. ```typescript nuxt.options.runtimeConfig.llms = { domain: options.domain, title: options.title, description: options.description, notes: options.notes || [], sections: options.sections || [] } ``` -------------------------------- ### Hook Signature Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Signature for the 'llms:generate:full' hook. ```typescript nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { // Hook implementations push content to the contents array contents.push('## Section\n\nContent...') }) ``` -------------------------------- ### Prerendering Routes Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Shows how endpoints are automatically added to prerender routes to ensure documentation is generated as static files. ```typescript addPrerenderRoutes('/llms.txt') addPrerenderRoutes('/llms-full.txt') // Only if full is configured ``` -------------------------------- ### Enable llms-full.txt route Source: https://github.com/nuxt-content/nuxt-llms/blob/main/README.md Enable the llms-full.txt route by setting full.title and full.description in nuxt.config.ts. ```typescript export default defineNuxtConfig({ llms: { domain: 'https://example.com', title: 'My Application', full: { title: 'Full Documentation', description: 'Full documentation of the application', }, }, }) ``` -------------------------------- ### Runtime Configuration Access Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Illustrates how to access the LLMs module configuration from the `runtimeConfig` in server-side code. ```typescript // In server context const { runtimeConfig } = useRuntimeConfig() const llmsConfig = runtimeConfig.llms // Type: ModuleOptions ``` -------------------------------- ### Enable Full Documentation Endpoint Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/endpoints.md To enable this endpoint, set the `full` option in `nuxt.config.ts`: ```typescript export default defineNuxtConfig({ llms: { domain: 'https://example.com', title: 'My Application', full: { title: 'Full Documentation', description: 'Extended documentation with detailed guides' } } }) ``` -------------------------------- ### Recommended Approach using Nitro Hooks Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md The recommended approach to hook into documentation generation, replacing onLLMsGenerate. ```typescript // Recommended approach (replaces onLLMsGenerate) export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate', (event, options) => { // Your code here }) }) ``` -------------------------------- ### `/llms-full.txt` Handler Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Details the functionality of the `/llms-full.txt` server route handler in nuxt-llms, including configuration loading, hook execution, content contribution, and response formatting. ```typescript // src/runtime/server/routes/llms-full.txt.get.ts - Loads configuration from runtimeConfig - Initializes empty contents array - Calls llms:generate:full hook (allows content contribution) - Joins contributed content sections - Sets Content-Type header - Returns plain text response ``` -------------------------------- ### Module Exports Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md The package exports are organized in two main entry points: the main module entry point and runtime utilities for server-side operations. ```typescript import { defineNuxtModule } from 'nuxt-llms' import type { ModuleOptions, LLMsSection } from 'nuxt-llms' // Runtime utilities (server-side) import { onLLMsGenerate, onLLMsGenerateFull } from 'nuxt-llms/runtime' ``` -------------------------------- ### Automatic Documentation Set Link Structure Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md The structure of the automatically inserted 'Documentation Sets' section when `options.full` is provided. ```typescript { title: 'Documentation Sets', links: [ { title: options.full.title, description: options.full.description, href: `${options.domain}/llms-full.txt` } ] } ``` -------------------------------- ### Configure application details Source: https://github.com/nuxt-content/nuxt-llms/blob/main/README.md Configure application details such as domain, title, description, and sections in nuxt.config.ts. ```typescript export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { domain: 'https://example.com', title: 'My Application', description: 'My Application Description', sections: [ { title: 'Section 1', description: 'Section 1 Description', links: [ { title: 'Link 1', description: 'Link 1 Description', href: '/link-1', }, { title: 'Link 2', description: 'Link 2 Description', href: '/link-2', }, ], }, ], }, }) ``` -------------------------------- ### Configuration Handling - Runtime Config Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Retrieves module configuration from Nitro runtime config. ```typescript const options = useRuntimeConfig(event).llms as ModuleOptions ``` -------------------------------- ### Notes Component Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Code for rendering the markdown notes section. ```typescript if (options.notes && options.notes.length) { document.push('## Notes') document.push((options.notes || []).map((note) => `- ${note}`).join('\n')) } ``` -------------------------------- ### Sections Component Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Code for rendering markdown sections. ```typescript for (const section of llms.sections) { document.push(`## ${section.title}`) if (section.description) { document.push(section.description) } // ... render links } ``` -------------------------------- ### Description Component Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Code for rendering the markdown description. ```typescript if (llms.description) { document.push(`> ${llms.description}`) } ``` -------------------------------- ### Title Component Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Code for rendering the markdown title. ```typescript const title = llms.title || 'Documentation' document.push(`# ${title}`) ``` -------------------------------- ### `/llms.txt` Handler Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Details the functionality of the `/llms.txt` server route handler in nuxt-llms, including configuration loading, hook execution, markdown rendering, and response formatting. ```typescript // src/runtime/server/routes/llms.txt.get.ts - Loads configuration from runtimeConfig - Calls llms:generate hook (allows modification) - Renders markdown from ModuleOptions - Sets Content-Type header - Returns plain text response ``` -------------------------------- ### Type Exports Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/module.md Shows how to import and use the ModuleOptions type from the 'nuxt-llms' package. ```typescript export type * from './runtime/types' ``` ```typescript import type { ModuleOptions, LLMsSection } from 'nuxt-llms' const config: ModuleOptions = { domain: 'https://example.com', sections: [] } ``` -------------------------------- ### Minimal Nuxt Configuration Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/README.md Minimal configuration for the nuxt-llms module, specifying the required domain. ```typescript export default defineNuxtConfig({ modules: ['nuxt-llms'], llms: { domain: 'https://example.com' } }) ``` -------------------------------- ### Route Definition Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-full-txt-handler.md Defines the HTTP request handler for the /llms-full.txt route. ```typescript export default eventHandler(async (event: H3Event) => { const options = useRuntimeConfig(event).llms as ModuleOptions const contents = [] as string[] const llms: ModuleOptions = JSON.parse(JSON.stringify(options)) await useNitroApp().hooks.callHook('llms:generate:full', event, llms, contents) await llmsHooks.callHook('generate:full', event, llms, contents) setHeader(event, 'Content-Type', 'text/plain; charset=utf-8') return contents.join('\n\n') }) ``` -------------------------------- ### Links Component Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Code for rendering markdown links within sections. ```typescript section.links ?.map((link) => { return link.description ? `- [${link.title}](${link.href}): ${link.description}` : `- [${link.title}](${link.href})` }) .join('\n') || '' ``` -------------------------------- ### Error Handling - Default Values Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Illustrates the default values used when specific configuration options are missing. ```typescript setHeader(event, 'Content-Type', 'text/plain; charset=utf-8') ``` -------------------------------- ### Document Join Behavior Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md Demonstrates how the document array is joined with double newlines for proper markdown formatting. ```typescript return document.join('\n\n') ``` -------------------------------- ### LLMsSection Interface Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/types.md Defines the structure for a documentation section, including title, description, and links. ```typescript export interface LLMsSection { title: string description?: string links?: Array<{ title: string description?: string href: string }> } ``` -------------------------------- ### Deprecation Note Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md Shows the recommended approach for registering hooks, replacing the deprecated onLLMsGenerateFull with the standard Nitro hook system. ```typescript // Recommended approach (replaces onLLMsGenerateFull) export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => { // Your code here }) }) ``` -------------------------------- ### Generated Markdown Structure Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/llms-txt-handler.md The expected structure of the markdown document generated by the handler. ```markdown # [Title] > [Description] ## [Section 1 Title] [Section 1 Description] - [Link 1 Title](link-href): [Link 1 Description] - [Link 2 Title](link-href) ## [Section 2 Title] [Section 2 Description] - [Link 1 Title](link-href): [Link 1 Description] ## Notes - [Note 1] - [Note 2] ``` -------------------------------- ### ModuleOptions Interface Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/types.md Defines the configuration options for the Nuxt LLMs module. ```typescript export interface ModuleOptions { /** * Domain of the documentation */ domain: string /** * Enable the full documentation */ full?: { title: string description: string } sections: Array title?: string description?: string notes?: string[] } ``` -------------------------------- ### llms.txt Response Structure Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/endpoints.md Plain text markdown following this structure: ```markdown # [Application Title] > [Application Description] ## [Section Title] [Section Description] - [Link Title](link-href): [Link Description] - [Link Title](link-href) ## Notes - [Note 1] - [Note 2] ``` -------------------------------- ### onLLMsGenerateFull TypeScript Signature Source: https://github.com/nuxt-content/nuxt-llms/blob/main/_autodocs/api-reference/hooks.md Registers a callback to be invoked when /llms-full.txt is being generated. ```typescript export function onLLMsGenerateFull( cb: (event: H3Event, options: ModuleOptions, contents: string[]) => void ): void ```