nuxt-llms 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,8 @@ Nuxt LLMs automatically generates [`llms.txt` markdown documentation](https://ll
13
13
 
14
14
  ## Features
15
15
 
16
- - Generates & prerenders `/llms.txt` and `/llms_full.txt` routes automatically
16
+ - Generates & prerenders `/llms.txt` automatically
17
+ - Generate & prerenders `/llms_full.txt` when enabled
17
18
  - Customizable sections directly from your `nuxt.config.ts`
18
19
  - Integrates with Nuxt modules and your application via the runtime hooks system
19
20
 
@@ -81,6 +82,144 @@ That's it! You can visit `/llms.txt` to see the generated documentation ✨
81
82
  - `description`: The description of the link
82
83
  - `href`(required): The href of the link
83
84
  - `notes`: The notes of the documentation. Notes are a special section which always appears at the end of the documentation. Notes are usefull to add any information about the application or documentation itself.
85
+ - `full`: The `llms_full.txt` configuration. Setting this option will enable the `llms_full.txt` route.
86
+ - `title`: The title of the llms_full documentation
87
+ - `description`: The description of the llms_full documentation
88
+
89
+ ## Documentation Formats
90
+
91
+ The module generates two different documentation formats:
92
+
93
+ ### llms.txt
94
+
95
+ The `/llms.txt` route generates a concise, structured documentation that follows the [llms.txt specification](https://llmstxt.org/). This format is optimized for both human readability and AI consumption. It includes:
96
+
97
+ - Application title and description
98
+ - Organized sections with titles and descriptions
99
+ - Links with titles, descriptions, and URLs
100
+ - Optional notes section
101
+
102
+ ### llms_full.txt
103
+
104
+ The `/llms_full.txt` route provides a more detailed, free-form documentation format. This is useful to reduce crawler traffic on your application and provide a more detailed documentation to your users and LLMs.
105
+
106
+ By default module does not generate the `llms_full.txt` route, you need to enable it by setting `full.title` and `full.description` in your `nuxt.config.ts`.
107
+
108
+ ```ts
109
+ export default defineNuxtConfig({
110
+ llms: {
111
+ domain: 'https://example.com',
112
+ title: 'My Application',
113
+ full: {
114
+ title: 'Full Documentation',
115
+ description: 'Full documentation of the application',
116
+ },
117
+ },
118
+ })
119
+ ```
120
+
121
+ ## Extending the documentation using hooks
122
+
123
+ The module provides a hooks system that allows you to dynamically extend both documentation formats. There are two main hooks:
124
+
125
+ ### Available Hooks
126
+
127
+ #### `generate:llms(event, options)`
128
+
129
+ This hook is called for every request to `/llms.txt`. Use this hook to modify the structured documentation, It allows you to add sections, links, and metadata.
130
+
131
+ **Parameters:**
132
+ - `event`: H3Event - The current request event
133
+ - `options`: ModuleOptions - The module options that you can modify to add sections, links, etc.
134
+
135
+
136
+ #### `generate:llms_full(event, options, contents)`
137
+
138
+ This hook is called for every request to `/llms_full.txt`. It allows you to add custom content sections in any format.
139
+
140
+ **Parameters:**
141
+ - `event`: H3Event - The current request event
142
+ - `options`: ModuleOptions - The module options that you can modify to add sections, links, etc.
143
+ - `contents`: string[] - Array of content sections you can add to or modify
144
+
145
+ ### Using Hooks in Your Application
146
+
147
+ Create a server plugin in your `server/plugins` directory:
148
+
149
+ ```ts
150
+ // server/plugins/llms.ts
151
+ import { onLLMsGenerate, onLLMsGenerateFull, llmsHooks } from 'nuxt-llms/runtime'
152
+
153
+ export default defineNitroPlugin(() => {
154
+ // Method 1: Using the hooks directly
155
+ llmsHooks.hook('generate', (event, options) => {
156
+ // Add a new section to llms.txt
157
+ options.sections.push({
158
+ title: 'API Documentation',
159
+ description: 'REST API endpoints and usage',
160
+ links: [
161
+ {
162
+ title: 'Authentication',
163
+ description: 'API authentication methods',
164
+ href: `${options.domain}/api/auth`
165
+ }
166
+ ]
167
+ })
168
+ })
169
+
170
+ // Method 2: Using the helper function
171
+ onLLMsGenerateFull((event, options, contents) => {
172
+ // Add detailed documentation to llms_full.txt
173
+ contents.push(`## API Authentication
174
+
175
+ ### Bearer Token
176
+ To authenticate API requests, include a Bearer token in the Authorization header:
177
+
178
+ \`\`\`
179
+ Authorization: Bearer <your-token>
180
+ \`\`\`
181
+
182
+ ### API Keys
183
+ For server-to-server communication, use API keys:
184
+
185
+ \`\`\`
186
+ X-API-Key: <your-api-key>
187
+ \`\`\`
188
+ `)
189
+ })
190
+ })
191
+ ```
192
+
193
+ ### Using Hooks in Nuxt Modules
194
+
195
+ If you're developing a Nuxt module that needs to extend the LLMs documentation:
196
+
197
+ 1. Create a server plugin in your module:
198
+ ```ts
199
+ // module/runtime/server/plugins/my-module-llms.ts
200
+ export default defineNitroPlugin(() => {
201
+ onLLMsGenerate((event, options) => {
202
+ options.sections.push({
203
+ title: 'My Module',
204
+ description: 'Documentation for my module features',
205
+ links: [/* ... */]
206
+ })
207
+ })
208
+ })
209
+ ```
210
+
211
+ 2. Register the plugin in your module setup:
212
+ ```ts
213
+ import { defineNuxtModule, addServerPlugin } from '@nuxt/kit'
214
+ import { fileURLToPath } from 'url'
215
+
216
+ export default defineNuxtModule({
217
+ setup(options, nuxt) {
218
+ const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
219
+ addServerPlugin(resolve(runtimeDir, 'server/plugins/my-module-llms'))
220
+ }
221
+ })
222
+ ```
84
223
 
85
224
  ## 💻 Development
86
225
 
package/dist/module.d.mts CHANGED
@@ -17,7 +17,7 @@ interface ModuleOptions {
17
17
  /**
18
18
  * Enable the full documentation
19
19
  */
20
- llmsFull?: {
20
+ full?: {
21
21
  title: string;
22
22
  description: string;
23
23
  };
package/dist/module.d.ts CHANGED
@@ -17,7 +17,7 @@ interface ModuleOptions {
17
17
  /**
18
18
  * Enable the full documentation
19
19
  */
20
- llmsFull?: {
20
+ full?: {
21
21
  title: string;
22
22
  description: string;
23
23
  };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "Nuxt LLMS",
3
3
  "configKey": "llms",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -23,13 +23,13 @@ const module = defineNuxtModule({
23
23
  addServerImports([{ name: "llmsHooks", from: resolve("./runtime/server/utils/hooks") }]);
24
24
  addServerHandler({ route: "/llms.txt", handler: resolve("./runtime/server/routes/llms.txt.get") });
25
25
  addPrerenderRoutes("/llms.txt");
26
- if (options.llmsFull) {
26
+ if (options.full) {
27
27
  llmsConfig.sections.unshift({
28
28
  title: "Documentation Sets",
29
29
  links: [
30
30
  {
31
- title: options.llmsFull.title,
32
- description: options.llmsFull.description,
31
+ title: options.full.title,
32
+ description: options.full.description,
33
33
  href: `${options.domain}/llms_full.txt`
34
34
  }
35
35
  ]
@@ -7,10 +7,10 @@ export default eventHandler(async (event) => {
7
7
  const llms = JSON.parse(JSON.stringify(options));
8
8
  await llmsHooks.callHook("generate:full", event, llms, contents);
9
9
  const document = [
10
- `# ${llms.llmsFull?.title || "Documentation"}`
10
+ `# ${llms.full?.title || "Documentation"}`
11
11
  ];
12
12
  if (llms.description) {
13
- document.push(`> ${llms.llmsFull?.description}`);
13
+ document.push(`> ${llms.full?.description}`);
14
14
  }
15
15
  for (const content of contents) {
16
16
  document.push(content);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-llms",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Generate llms.txt documentation for your Nuxt application",
5
5
  "repository": {
6
6
  "type": "git",