nuxt-llms 0.0.2 → 0.1.1

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
@@ -1,3 +1,5 @@
1
+ ![nuxt-llms-social-card](https://github.com/user-attachments/assets/4570398c-0e49-4199-bc30-ab72f6680f4b)
2
+
1
3
  # Nuxt LLMs
2
4
 
3
5
  [![npm version][npm-version-src]][npm-version-href]
@@ -14,7 +16,7 @@ Nuxt LLMs automatically generates [`llms.txt` markdown documentation](https://ll
14
16
  ## Features
15
17
 
16
18
  - Generates & prerenders `/llms.txt` automatically
17
- - Generate & prerenders `/llms_full.txt` when enabled
19
+ - Generate & prerenders `/llms-full.txt` when enabled
18
20
  - Customizable sections directly from your `nuxt.config.ts`
19
21
  - Integrates with Nuxt modules and your application via the runtime hooks system
20
22
 
@@ -81,10 +83,10 @@ That's it! You can visit `/llms.txt` to see the generated documentation ✨
81
83
  - `title`(required): The title of the link
82
84
  - `description`: The description of the link
83
85
  - `href`(required): The href of the link
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
86
+ - `notes`: The notes of the documentation. Notes are a special section which always appears at the end of the documentation. Notes are useful to add any information about the application or documentation itself.
87
+ - `full`: The `llms-full.txt` configuration. Setting this option will enable the `llms-full.txt` route.
88
+ - `title`: The title of the llms-full documentation
89
+ - `description`: The description of the llms-full documentation
88
90
 
89
91
  ## Documentation Formats
90
92
 
@@ -99,11 +101,11 @@ The `/llms.txt` route generates a concise, structured documentation that follows
99
101
  - Links with titles, descriptions, and URLs
100
102
  - Optional notes section
101
103
 
102
- ### llms_full.txt
104
+ ### llms-full.txt
103
105
 
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.
106
+ 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
107
 
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`.
108
+ 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
109
 
108
110
  ```ts
109
111
  export default defineNuxtConfig({
@@ -124,7 +126,7 @@ The module provides a hooks system that allows you to dynamically extend both do
124
126
 
125
127
  ### Available Hooks
126
128
 
127
- #### `generate:llms(event, options)`
129
+ #### `llms:generate(event, options)`
128
130
 
129
131
  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
132
 
@@ -133,9 +135,9 @@ This hook is called for every request to `/llms.txt`. Use this hook to modify th
133
135
  - `options`: ModuleOptions - The module options that you can modify to add sections, links, etc.
134
136
 
135
137
 
136
- #### `generate:llms_full(event, options, contents)`
138
+ #### `llms:generate:llms-full(event, options, contents)`
137
139
 
138
- This hook is called for every request to `/llms_full.txt`. It allows you to add custom content sections in any format.
140
+ This hook is called for every request to `/llms-full.txt`. It allows you to add custom content sections in any format.
139
141
 
140
142
  **Parameters:**
141
143
  - `event`: H3Event - The current request event
@@ -148,11 +150,9 @@ Create a server plugin in your `server/plugins` directory:
148
150
 
149
151
  ```ts
150
152
  // server/plugins/llms.ts
151
- import { onLLMsGenerate, onLLMsGenerateFull, llmsHooks } from 'nuxt-llms/runtime'
152
-
153
- export default defineNitroPlugin(() => {
153
+ export default defineNitroPlugin((nitroApp) => {
154
154
  // Method 1: Using the hooks directly
155
- llmsHooks.hook('generate', (event, options) => {
155
+ nitroApp.hooks.hook('llms:generate', (event, options) => {
156
156
  // Add a new section to llms.txt
157
157
  options.sections.push({
158
158
  title: 'API Documentation',
@@ -168,8 +168,8 @@ export default defineNitroPlugin(() => {
168
168
  })
169
169
 
170
170
  // Method 2: Using the helper function
171
- onLLMsGenerateFull((event, options, contents) => {
172
- // Add detailed documentation to llms_full.txt
171
+ nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => {
172
+ // Add detailed documentation to llms-full.txt
173
173
  contents.push(`## API Authentication
174
174
 
175
175
  ### Bearer Token
@@ -197,8 +197,8 @@ If you're developing a Nuxt module that needs to extend the LLMs documentation:
197
197
  1. Create a server plugin in your module:
198
198
  ```ts
199
199
  // module/runtime/server/plugins/my-module-llms.ts
200
- export default defineNitroPlugin(() => {
201
- onLLMsGenerate((event, options) => {
200
+ export default defineNitroPlugin((nitroApp) => {
201
+ nitroApp.hooks.hook('llms:generate', (event, options) => {
202
202
  options.sections.push({
203
203
  title: 'My Module',
204
204
  description: 'Documentation for my module features',
@@ -221,6 +221,29 @@ export default defineNuxtModule({
221
221
  })
222
222
  ```
223
223
 
224
+ ## Integrations
225
+
226
+ ### Nuxt Content
227
+
228
+ Nuxt Content ^3.2.0 comes with built-in support for LLMs documentation. You can use `nuxt-llms` with `@nuxt/content` to efficiently write content and documentation for your website and generate LLM-friendly documentation without extra effort. Content module uses `nuxt-llms` hooks and automatically adds all your contents into `llms.txt` and `llms-full.txt` documentation.
229
+
230
+ All you need is to install both modules and write your content files in the `content` directory.
231
+
232
+ ```ts
233
+ export default defineNuxtConfig({
234
+ modules: ['nuxt-llms', '@nuxt/content'],
235
+ llms: {
236
+ domain: 'https://example.com',
237
+ title: 'My Application',
238
+ description: 'My Application Description',
239
+ },
240
+ })
241
+ ```
242
+
243
+ Checkout the [Nuxt Content documentation](https://content.nuxt.com/docs/usage/content-pages) for more information on how to write your content files.
244
+
245
+ And checkout the [Nuxt Content llms documentation](https://content.nuxt.com/docs/advanced/llms) for more information on how to customize LLMs contents with `nuxt-llms` and `@nuxt/content`.
246
+
224
247
  ## 💻 Development
225
248
 
226
249
  - Clone repository
package/dist/module.d.mts CHANGED
@@ -1,32 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- interface LLMsSection {
4
- title: string;
5
- description?: string;
6
- links?: Array<{
7
- title: string;
8
- description?: string;
9
- href: string;
10
- }>;
11
- }
12
- interface ModuleOptions {
13
- /**
14
- * Domain of the documentation
15
- */
16
- domain: string;
17
- /**
18
- * Enable the full documentation
19
- */
20
- full?: {
21
- title: string;
22
- description: string;
23
- };
24
- sections: Array<LLMsSection>;
25
- title?: string;
26
- description?: string;
27
- notes?: string[];
28
- }
2
+ import { ModuleOptions } from '../dist/runtime/types.js';
3
+ export * from '../dist/runtime/types.js';
29
4
 
30
5
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
31
6
 
32
- export { type LLMsSection, type ModuleOptions, _default as default };
7
+ export { _default as default };
package/dist/module.d.ts CHANGED
@@ -1,32 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- interface LLMsSection {
4
- title: string;
5
- description?: string;
6
- links?: Array<{
7
- title: string;
8
- description?: string;
9
- href: string;
10
- }>;
11
- }
12
- interface ModuleOptions {
13
- /**
14
- * Domain of the documentation
15
- */
16
- domain: string;
17
- /**
18
- * Enable the full documentation
19
- */
20
- full?: {
21
- title: string;
22
- description: string;
23
- };
24
- sections: Array<LLMsSection>;
25
- title?: string;
26
- description?: string;
27
- notes?: string[];
28
- }
2
+ import { ModuleOptions } from '../dist/runtime/types.js';
3
+ export * from '../dist/runtime/types.js';
29
4
 
30
5
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
31
6
 
32
- export { type LLMsSection, type ModuleOptions, _default as default };
7
+ export { _default as default };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "Nuxt LLMS",
3
3
  "configKey": "llms",
4
- "version": "0.0.2",
4
+ "version": "0.1.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -30,12 +30,12 @@ const module = defineNuxtModule({
30
30
  {
31
31
  title: options.full.title,
32
32
  description: options.full.description,
33
- href: `${options.domain}/llms_full.txt`
33
+ href: `${options.domain}/llms-full.txt`
34
34
  }
35
35
  ]
36
36
  });
37
- addServerHandler({ route: "/llms_full.txt", handler: resolve("./runtime/server/routes/llms_full.txt.get") });
38
- addPrerenderRoutes("/llms_full.txt");
37
+ addServerHandler({ route: "/llms-full.txt", handler: resolve("./runtime/server/routes/llms-full.txt.get") });
38
+ addPrerenderRoutes("/llms-full.txt");
39
39
  }
40
40
  }
41
41
  });
@@ -1,20 +1,12 @@
1
1
  import { eventHandler, setHeader } from "h3";
2
2
  import { llmsHooks } from "nuxt-llms/runtime";
3
- import { useRuntimeConfig } from "#imports";
3
+ import { useRuntimeConfig, useNitroApp } from "#imports";
4
4
  export default eventHandler(async (event) => {
5
5
  const options = useRuntimeConfig(event).llms;
6
6
  const contents = [];
7
7
  const llms = JSON.parse(JSON.stringify(options));
8
+ await useNitroApp().hooks.callHook("llms:generate:full", event, llms, contents);
8
9
  await llmsHooks.callHook("generate:full", event, llms, contents);
9
- const document = [
10
- `# ${llms.full?.title || "Documentation"}`
11
- ];
12
- if (llms.description) {
13
- document.push(`> ${llms.full?.description}`);
14
- }
15
- for (const content of contents) {
16
- document.push(content);
17
- }
18
- setHeader(event, "Content-Type", "text/plain");
10
+ setHeader(event, "Content-Type", "text/plain; charset=utf-8");
19
11
  return contents.join("\n\n");
20
12
  });
@@ -1,9 +1,10 @@
1
1
  import { eventHandler, setHeader } from "h3";
2
2
  import { llmsHooks } from "nuxt-llms/runtime";
3
- import { useRuntimeConfig } from "#imports";
3
+ import { useRuntimeConfig, useNitroApp } from "#imports";
4
4
  export default eventHandler(async (event) => {
5
5
  const options = useRuntimeConfig(event).llms;
6
6
  const llms = JSON.parse(JSON.stringify(options));
7
+ await useNitroApp().hooks.callHook("llms:generate", event, llms);
7
8
  await llmsHooks.callHook("generate", event, llms);
8
9
  const document = [
9
10
  `# ${llms.title || "Documentation"}`
@@ -28,6 +29,6 @@ export default eventHandler(async (event) => {
28
29
  (options.notes || []).map((note) => `- ${note}`).join("\n")
29
30
  );
30
31
  }
31
- setHeader(event, "Content-Type", "text/plain");
32
+ setHeader(event, "Content-Type", "text/plain; charset=utf-8");
32
33
  return document.join("\n\n");
33
34
  });
@@ -1,15 +1,26 @@
1
1
  import type { H3Event } from 'h3';
2
2
  import type { ModuleOptions } from 'nuxt-llms';
3
+ import type { NitroRuntimeHooks } from 'nitropack/types';
4
+ /**
5
+ * @deprecated Custom hooks are deprecated in favor of NitroRuntimeHooks.
6
+ */
3
7
  export interface LLMSHooks {
4
8
  'generate': (event: H3Event, options: ModuleOptions) => void;
5
9
  'generate:full': (event: H3Event, options: ModuleOptions, contents: string[]) => void;
6
10
  }
11
+ /**
12
+ * @deprecated Custom hooks are deprecated in favor of NitroRuntimeHooks.
13
+ */
7
14
  export declare const llmsHooks: import("hookable").Hookable<LLMSHooks, import("hookable").HookKeys<LLMSHooks>>;
8
15
  /**
9
16
  * Run a callback when LLMs is being generated.
17
+ *
18
+ * @deprecated Use `useNitroApp().hooks.hook('llms:generate', (event, options) => {})` instead
10
19
  */
11
- export declare function onLLMsGenerate(cb: LLMSHooks['generate']): () => void;
20
+ export declare function onLLMsGenerate(cb: NitroRuntimeHooks['llms:generate']): any;
12
21
  /**
13
22
  * Run a callback when Full LLMs is being generated.
23
+ *
24
+ * @deprecated Use `useNitroApp().hooks.hook('llms:generate:full', (event, options, contents) => {})` instead
14
25
  */
15
- export declare function onLLMsGenerateFull(cb: LLMSHooks['generate:full']): () => void;
26
+ export declare function onLLMsGenerateFull(cb: NitroRuntimeHooks['llms:generate:full']): any;
@@ -1,8 +1,12 @@
1
1
  import { createHooks } from "hookable";
2
+ import { useNitroApp } from "#imports";
2
3
  export const llmsHooks = createHooks();
4
+ llmsHooks.beforeEach(() => {
5
+ console.warn("[nuxt-llms] `llmsHooks` are deprecated and will be removed in future versions. Use `useNitroApp().hooks.hook('llms:generate', (event, options) => {})` instead");
6
+ });
3
7
  export function onLLMsGenerate(cb) {
4
- return llmsHooks.hook("generate", cb);
8
+ return useNitroApp().hooks.hook("llms:generate", cb);
5
9
  }
6
10
  export function onLLMsGenerateFull(cb) {
7
- return llmsHooks.hook("generate:full", cb);
11
+ return useNitroApp().hooks.hook("llms:generate:full", cb);
8
12
  }
@@ -0,0 +1,33 @@
1
+ import type { H3Event } from 'h3';
2
+ declare module 'nitropack/types' {
3
+ interface NitroRuntimeHooks {
4
+ 'llms:generate': (event: H3Event, options: ModuleOptions) => void;
5
+ 'llms:generate:full': (event: H3Event, options: ModuleOptions, contents: string[]) => void;
6
+ }
7
+ }
8
+ export interface LLMsSection {
9
+ title: string;
10
+ description?: string;
11
+ links?: Array<{
12
+ title: string;
13
+ description?: string;
14
+ href: string;
15
+ }>;
16
+ }
17
+ export interface ModuleOptions {
18
+ /**
19
+ * Domain of the documentation
20
+ */
21
+ domain: string;
22
+ /**
23
+ * Enable the full documentation
24
+ */
25
+ full?: {
26
+ title: string;
27
+ description: string;
28
+ };
29
+ sections: Array<LLMsSection>;
30
+ title?: string;
31
+ description?: string;
32
+ notes?: string[];
33
+ }
File without changes
package/dist/types.d.mts CHANGED
@@ -1 +1,7 @@
1
- export { type LLMsSection, type ModuleOptions, default } from './module.js'
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module.js'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1 +1,7 @@
1
- export { type LLMsSection, type ModuleOptions, default } from './module'
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-llms",
3
- "version": "0.0.2",
3
+ "version": "0.1.1",
4
4
  "description": "Generate llms.txt documentation for your Nuxt application",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,7 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
- "types": "./dist/types.d.ts",
13
+ "types": "./dist/module.d.ts",
14
14
  "import": "./dist/module.mjs",
15
15
  "require": "./dist/module.cjs"
16
16
  },
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "main": "./dist/module.cjs",
24
- "types": "./dist/types.d.ts",
24
+ "types": "./dist/module.d.ts",
25
25
  "files": [
26
26
  "dist"
27
27
  ],
@@ -39,22 +39,22 @@
39
39
  "verify": "npm run dev:prepare && npm run lint && npm run test && npm run typecheck"
40
40
  },
41
41
  "dependencies": {
42
- "@nuxt/kit": "^3.15.4"
42
+ "@nuxt/kit": "^3.16.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "nuxt-llms": "link:.",
46
- "@nuxt/devtools": "^2.1.0",
47
- "@nuxt/eslint-config": "^1.1.0",
46
+ "@nuxt/devtools": "^2.3.1",
47
+ "@nuxt/eslint-config": "^1.2.0",
48
48
  "@nuxt/module-builder": "^0.8.4",
49
- "@nuxt/schema": "^3.15.4",
50
- "@nuxt/test-utils": "^3.15.4",
49
+ "@nuxt/schema": "^3.16.1",
50
+ "@nuxt/test-utils": "^3.17.2",
51
51
  "@types/node": "latest",
52
- "changelogen": "^0.5.7",
53
- "eslint": "^9.20.1",
54
- "nuxt": "^3.15.4",
52
+ "changelogen": "^0.6.1",
53
+ "eslint": "^9.23.0",
54
+ "nuxt": "^3.16.1",
55
55
  "typescript": "~5.6.0",
56
- "vitest": "^3.0.6",
56
+ "vitest": "^3.0.9",
57
57
  "vue-tsc": "^2.2.2"
58
58
  },
59
- "packageManager": "pnpm@10.4.1"
59
+ "packageManager": "pnpm@10.6.5"
60
60
  }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../../.nuxt/tsconfig.server.json",
3
- }