nuxt-llms 0.0.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/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +32 -0
- package/dist/module.d.ts +32 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +43 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/server/routes/llms.txt.get.d.ts +2 -0
- package/dist/runtime/server/routes/llms.txt.get.js +33 -0
- package/dist/runtime/server/routes/llms_full.txt.get.d.ts +2 -0
- package/dist/runtime/server/routes/llms_full.txt.get.js +20 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/hooks.d.ts +15 -0
- package/dist/runtime/server/utils/hooks.js +8 -0
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Nuxt Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Nuxt LLMs
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![License][license-src]][license-href]
|
|
6
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
7
|
+
|
|
8
|
+
Nuxt LLMs automatically generates [`llms.txt` markdown documentation](https://llmstxt.org/) for your Nuxt application. It provides runtime hooks to collect data from various sources (CMS, Nuxt Content, etc.) and generate structured documentation in a text-based format.
|
|
9
|
+
|
|
10
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
11
|
+
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/nuxt-llms?file=playground%2Fapp.vue) -->
|
|
12
|
+
<!-- - [📖 Documentation](https://example.com) -->
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Generates & prerenders `/llms.txt` and `/llms_full.txt` routes automatically
|
|
17
|
+
- Customizable sections directly from your `nuxt.config.ts`
|
|
18
|
+
- Integrates with Nuxt modules and your application via the runtime hooks system
|
|
19
|
+
|
|
20
|
+
## Quick Setup
|
|
21
|
+
|
|
22
|
+
1. Install the module:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm i nuxt-llms
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Register `nuxt-llms` in your `nuxt.config.ts`:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
export default defineNuxtConfig({
|
|
32
|
+
modules: ['nuxt-llms']
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. Configure your application details:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
export default defineNuxtConfig({
|
|
40
|
+
modules: ['nuxt-llms'],
|
|
41
|
+
llms: {
|
|
42
|
+
domain: 'https://example.com',
|
|
43
|
+
title: 'My Application',
|
|
44
|
+
description: 'My Application Description',
|
|
45
|
+
sections: [
|
|
46
|
+
{
|
|
47
|
+
title: 'Section 1',
|
|
48
|
+
description: 'Section 1 Description',
|
|
49
|
+
links: [
|
|
50
|
+
{
|
|
51
|
+
title: 'Link 1',
|
|
52
|
+
description: 'Link 1 Description',
|
|
53
|
+
href: '/link-1',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: 'Link 2',
|
|
57
|
+
description: 'Link 2 Description',
|
|
58
|
+
href: '/link-2',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
That's it! You can visit `/llms.txt` to see the generated documentation ✨
|
|
68
|
+
|
|
69
|
+
## Options
|
|
70
|
+
|
|
71
|
+
- `domain`(required): The domain of the application
|
|
72
|
+
- `title`: The title of the application, will be displayed at the top of the documentation
|
|
73
|
+
- `description`: The description of the application, will be displayed at the top of the documentation right after the title
|
|
74
|
+
- `sections`: The sections of the documentation.
|
|
75
|
+
Section are consisted of a title, one or more paragraphs of description and possibly a list of links.
|
|
76
|
+
Each section is an object with the following properties:
|
|
77
|
+
- `title`(required): The title of the section
|
|
78
|
+
- `description`: The description of the section
|
|
79
|
+
- `links`: The links of the section
|
|
80
|
+
- `title`(required): The title of the link
|
|
81
|
+
- `description`: The description of the link
|
|
82
|
+
- `href`(required): The href of the link
|
|
83
|
+
- `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.
|
|
84
|
+
|
|
85
|
+
## 💻 Development
|
|
86
|
+
|
|
87
|
+
- Clone repository
|
|
88
|
+
- Install dependencies using `pnpm install`
|
|
89
|
+
- Prepare using `pnpm dev:prepare`
|
|
90
|
+
- Build using `pnpm prepack`
|
|
91
|
+
- Try playground using `pnpm dev`
|
|
92
|
+
- Test using `pnpm test`
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
[MIT License](LICENSE)
|
|
97
|
+
|
|
98
|
+
Copyright (c) NuxtLabs
|
|
99
|
+
|
|
100
|
+
<!-- Badges -->
|
|
101
|
+
[npm-version-src]: https://img.shields.io/npm/v/nuxt-llms/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
102
|
+
[npm-version-href]: https://npmjs.com/package/nuxt-llms
|
|
103
|
+
|
|
104
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-llms.svg?style=flat&colorA=020420&colorB=00DC82
|
|
105
|
+
[npm-downloads-href]: https://npm.chart.dev/nuxt-llms
|
|
106
|
+
|
|
107
|
+
[license-src]: https://img.shields.io/npm/l/nuxt-llms.svg?style=flat&colorA=020420&colorB=00DC82
|
|
108
|
+
[license-href]: https://npmjs.com/package/nuxt-llms
|
|
109
|
+
|
|
110
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
|
|
111
|
+
[nuxt-href]: https://nuxt.com
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
llmsFull?: {
|
|
21
|
+
title: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
sections: Array<LLMsSection>;
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
notes?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
31
|
+
|
|
32
|
+
export { type LLMsSection, type ModuleOptions, _default as default };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
llmsFull?: {
|
|
21
|
+
title: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
sections: Array<LLMsSection>;
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
notes?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
31
|
+
|
|
32
|
+
export { type LLMsSection, type ModuleOptions, _default as default };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineNuxtModule, useLogger, createResolver, addServerImports, addServerHandler, addPrerenderRoutes } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const module = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "Nuxt LLMS",
|
|
6
|
+
configKey: "llms"
|
|
7
|
+
},
|
|
8
|
+
defaults: {},
|
|
9
|
+
setup(options, nuxt) {
|
|
10
|
+
const logger = useLogger("nuxt-llms");
|
|
11
|
+
const { resolve } = createResolver(import.meta.url);
|
|
12
|
+
const llmsConfig = nuxt.options.runtimeConfig.llms = {
|
|
13
|
+
domain: options.domain,
|
|
14
|
+
title: options.title,
|
|
15
|
+
description: options.description,
|
|
16
|
+
notes: options.notes || [],
|
|
17
|
+
sections: options.sections || []
|
|
18
|
+
};
|
|
19
|
+
if (!options.domain) {
|
|
20
|
+
logger.warn("nuxt-llms require a domain to be set. `llms.domain` is missing.");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
addServerImports([{ name: "llmsHooks", from: resolve("./runtime/server/utils/hooks") }]);
|
|
24
|
+
addServerHandler({ route: "/llms.txt", handler: resolve("./runtime/server/routes/llms.txt.get") });
|
|
25
|
+
addPrerenderRoutes("/llms.txt");
|
|
26
|
+
if (options.llmsFull) {
|
|
27
|
+
llmsConfig.sections.unshift({
|
|
28
|
+
title: "Documentation Sets",
|
|
29
|
+
links: [
|
|
30
|
+
{
|
|
31
|
+
title: options.llmsFull.title,
|
|
32
|
+
description: options.llmsFull.description,
|
|
33
|
+
href: `${options.domain}/llms_full.txt`
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
addServerHandler({ route: "/llms_full.txt", handler: resolve("./runtime/server/routes/llms_full.txt.get") });
|
|
38
|
+
addPrerenderRoutes("/llms_full.txt");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export { module as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './server/utils/hooks.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./server/utils/hooks.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { eventHandler, setHeader } from "h3";
|
|
2
|
+
import { llmsHooks } from "nuxt-llms/runtime";
|
|
3
|
+
import { useRuntimeConfig } from "#imports";
|
|
4
|
+
export default eventHandler(async (event) => {
|
|
5
|
+
const options = useRuntimeConfig(event).llms;
|
|
6
|
+
const llms = JSON.parse(JSON.stringify(options));
|
|
7
|
+
await llmsHooks.callHook("generate", event, llms);
|
|
8
|
+
const document = [
|
|
9
|
+
`# ${llms.title || "Documentation"}`
|
|
10
|
+
];
|
|
11
|
+
if (llms.description) {
|
|
12
|
+
document.push(`> ${options.description}`);
|
|
13
|
+
}
|
|
14
|
+
for (const section of llms.sections) {
|
|
15
|
+
document.push(`## ${section.title}`);
|
|
16
|
+
if (section.description) {
|
|
17
|
+
document.push(section.description);
|
|
18
|
+
}
|
|
19
|
+
document.push(
|
|
20
|
+
section.links?.map((link) => {
|
|
21
|
+
return `- [${link.title}](${link.href}): ${link.description}`;
|
|
22
|
+
}).join("\n") || ""
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (options.notes && options.notes.length) {
|
|
26
|
+
document.push(
|
|
27
|
+
"## Notes",
|
|
28
|
+
(options.notes || []).map((note) => `- ${note}`).join("\n")
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
setHeader(event, "Content-Type", "text/plain");
|
|
32
|
+
return document.join("\n\n");
|
|
33
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { eventHandler, setHeader } from "h3";
|
|
2
|
+
import { llmsHooks } from "nuxt-llms/runtime";
|
|
3
|
+
import { useRuntimeConfig } from "#imports";
|
|
4
|
+
export default eventHandler(async (event) => {
|
|
5
|
+
const options = useRuntimeConfig(event).llms;
|
|
6
|
+
const contents = [];
|
|
7
|
+
const llms = JSON.parse(JSON.stringify(options));
|
|
8
|
+
await llmsHooks.callHook("generate:full", event, llms, contents);
|
|
9
|
+
const document = [
|
|
10
|
+
`# ${llms.llmsFull?.title || "Documentation"}`
|
|
11
|
+
];
|
|
12
|
+
if (llms.description) {
|
|
13
|
+
document.push(`> ${llms.llmsFull?.description}`);
|
|
14
|
+
}
|
|
15
|
+
for (const content of contents) {
|
|
16
|
+
document.push(content);
|
|
17
|
+
}
|
|
18
|
+
setHeader(event, "Content-Type", "text/plain");
|
|
19
|
+
return contents.join("\n\n");
|
|
20
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { ModuleOptions } from 'nuxt-llms';
|
|
3
|
+
export interface LLMSHooks {
|
|
4
|
+
'generate': (event: H3Event, options: ModuleOptions) => void;
|
|
5
|
+
'generate:full': (event: H3Event, options: ModuleOptions, contents: string[]) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const llmsHooks: import("hookable").Hookable<LLMSHooks, import("hookable").HookKeys<LLMSHooks>>;
|
|
8
|
+
/**
|
|
9
|
+
* Run a callback when LLMs is being generated.
|
|
10
|
+
*/
|
|
11
|
+
export declare function onLLMsGenerate(cb: LLMSHooks['generate']): () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Run a callback when Full LLMs is being generated.
|
|
14
|
+
*/
|
|
15
|
+
export declare function onLLMsGenerateFull(cb: LLMSHooks['generate:full']): () => void;
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type LLMsSection, type ModuleOptions, default } from './module.js'
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type LLMsSection, type ModuleOptions, default } from './module'
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nuxt-llms",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Generate llms.txt documentation for your Nuxt application",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/nuxtlabs/nuxt-llms.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/types.d.ts",
|
|
14
|
+
"import": "./dist/module.mjs",
|
|
15
|
+
"require": "./dist/module.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./runtime": {
|
|
18
|
+
"types": "./dist/runtime/index.d.ts",
|
|
19
|
+
"import": "./dist/runtime/index.js",
|
|
20
|
+
"require": "./dist/runtime/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/module.cjs",
|
|
24
|
+
"types": "./dist/types.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"prepack": "nuxt-module-build build",
|
|
30
|
+
"dev": "nuxi dev playground",
|
|
31
|
+
"dev:build": "nuxi build playground",
|
|
32
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
33
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"typecheck": "nuxi typecheck",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest watch",
|
|
38
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
39
|
+
"verify": "npm run dev:prepare && npm run lint && npm run test && npm run typecheck"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@nuxt/kit": "^3.15.4"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"nuxt-llms": "link:.",
|
|
46
|
+
"@nuxt/devtools": "^2.1.0",
|
|
47
|
+
"@nuxt/eslint-config": "^1.1.0",
|
|
48
|
+
"@nuxt/module-builder": "^0.8.4",
|
|
49
|
+
"@nuxt/schema": "^3.15.4",
|
|
50
|
+
"@nuxt/test-utils": "^3.15.4",
|
|
51
|
+
"@types/node": "latest",
|
|
52
|
+
"changelogen": "^0.5.7",
|
|
53
|
+
"eslint": "^9.20.1",
|
|
54
|
+
"nuxt": "^3.15.4",
|
|
55
|
+
"typescript": "~5.6.0",
|
|
56
|
+
"vitest": "^3.0.6",
|
|
57
|
+
"vue-tsc": "^2.2.2"
|
|
58
|
+
},
|
|
59
|
+
"packageManager": "pnpm@10.4.1"
|
|
60
|
+
}
|