Skip to content

Commit eb0f642

Browse files
committed
feat(vitepress-theme): add vitepress-plugin-llms for auto llms.txt generation
1 parent e7c5cb7 commit eb0f642

File tree

5 files changed

+221
-21
lines changed

5 files changed

+221
-21
lines changed

docs/vitepress-theme/features/copy-as-markdown.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,35 @@ All options are enabled by default but can be controlled per-page using frontmat
2727

2828
## Generating llms.txt Files
2929

30-
To generate `llms.txt` and `llms-full.txt` files in your repository root, use the mdream CLI after building your docs:
30+
The theme automatically generates `llms.txt` and `llms-full.txt` files during build when using `vitepress-plugin-llms` (enabled by default in `NimiqVitepressVitePlugin`).
31+
32+
After building your docs:
3133

3234
```bash
33-
# Build the documentation
3435
pnpm docs:build
36+
```
37+
38+
This automatically creates in `.vitepress/dist/`:
39+
40+
- `llms.txt` - A sitemap of all documentation pages
41+
- `llms-full.txt` - Complete markdown content of all pages
42+
- `markdown/` directory - Individual markdown files for each page
43+
44+
### Manual Generation (Alternative)
3545

36-
# Generate llms.txt files in the root
46+
You can also generate llms.txt files manually using the mdream CLI:
47+
48+
```bash
3749
pnpm dlx mdream llms "docs/.vitepress/dist/**/*.html" \
3850
--site-name "My Docs" \
3951
--description "My awesome documentation" \
4052
--origin "https://docs.example.com" \
4153
-o .
4254
```
4355

44-
This will create:
45-
46-
- `llms.txt` - A sitemap of all documentation pages
47-
- `llms-full.txt` - Complete markdown content of all pages
48-
- `markdown/` directory - Individual markdown files for each page
49-
5056
## Configuration
5157

52-
The markdown generation is automatically configured when you use the `NimiqVitepressVitePlugin`:
58+
The llms.txt generation is automatically configured when you use the `NimiqVitepressVitePlugin`:
5359

5460
```ts [vite.config.ts]
5561
import { NimiqVitepressVitePlugin } from 'nimiq-vitepress-theme/vite'
@@ -59,13 +65,13 @@ export default defineConfig({
5965
NimiqVitepressVitePlugin({
6066
repoURL: 'https://github.com/your-org/your-repo',
6167

62-
// LLM-friendly markdown generation
68+
// LLMs.txt automatic generation (enabled by default)
6369
llms: {
64-
domain: 'https://docs.example.com',
65-
injectLLMHint: false
70+
// Pass options to vitepress-plugin-llms
71+
// See: https://github.com/okineadev/vitepress-plugin-llms#options
6672
}
6773

68-
// Or disable it entirely
74+
// Or disable automatic llms.txt generation
6975
// llms: false
7076
})
7177
]
@@ -74,9 +80,9 @@ export default defineConfig({
7480

7581
### Plugin Options
7682

77-
| Option | Type | Default | Description |
78-
| ------ | ------------------- | ------- | -------------------------------------------------------------- |
79-
| `llms` | `object \| boolean` | `true` | LLM-friendly markdown generation options or `false` to disable |
83+
| Option | Type | Default | Description |
84+
| ------ | ------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
85+
| `llms` | `object \| boolean` | `true` | Automatic llms.txt generation via `vitepress-plugin-llms`. Pass config object or `false` to disable. See [plugin docs](https://github.com/okineadev/vitepress-plugin-llms#options) for available options. |
8086

8187
## Per-Page Control
8288

packages/nimiq-css/src/css/colors.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,4 @@
7979
--colors-gold-gradient-darkened-from: light-dark(oklab(0.7143 0.0695 0.1390), oklab(0.8163 0.0458 0.1479));
8080
--colors-gold-gradient-darkened-to: light-dark(oklab(0.7575 0.0315 0.1515), oklab(0.8221 0.0167 0.1498));
8181
--colors-gold-gradient-darkened: radial-gradient(at 100% 100% in oklab, var(--colors-gold-gradient-darkened-from), var(--colors-gold-gradient-darkened-to));
82-
--colors-purple-gradient-from: light-dark(oklab(0.3356 0.0227 -0.0760), oklab(0.3356 0.0227 -0.0760));
83-
--colors-purple-gradient-to: light-dark(oklab(0.3414 0.0439 -0.0787), oklab(0.3414 0.0439 -0.0787));
84-
--colors-purple-gradient: radial-gradient(at 100% 100% in oklab, var(--colors-purple-gradient-from), var(--colors-purple-gradient-to));
8582
}

packages/nimiq-vitepress-theme/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"unbuild": "catalog:build",
100100
"unocss": "catalog:style",
101101
"unocss-preset-animations": "catalog:style",
102-
"unocss-preset-onmax": "catalog:style"
102+
"unocss-preset-onmax": "catalog:style",
103+
"vitepress-plugin-llms": "^1.8.1"
103104
}
104105
}

packages/nimiq-vitepress-theme/src/vite/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import path from 'node:path'
55
import process from 'node:process'
66
import { viteHtmlToMarkdownPlugin } from '@mdream/vite'
77
import { GitChangelog } from '@nolebase/vitepress-plugin-git-changelog/vite'
8+
import llmstxt from 'vitepress-plugin-llms'
89
import { groupIconVitePlugin } from '../code-groups/vite'
910

1011
type GitChangelogOptions = Parameters<typeof GitChangelog>[0]
12+
type LlmsPluginOptions = Parameters<typeof llmstxt>[0]
1113

1214
export interface NimiqVitepressVitePluginOptions {
1315
/**
@@ -29,6 +31,14 @@ export interface NimiqVitepressVitePluginOptions {
2931
* Set to false to disable changelog
3032
*/
3133
gitChangelog?: GitChangelogOptions | false
34+
35+
/**
36+
* LLMs.txt plugin configuration
37+
* Automatically generates llms.txt and llms-full.txt during build
38+
* Set to false to disable (only mdream markdown generation will be used)
39+
* @default true
40+
*/
41+
llms?: LlmsPluginOptions | boolean
3242
}
3343

3444
function getProjectVersion(rootDir: string = process.cwd()): string | undefined {
@@ -49,6 +59,7 @@ export function NimiqVitepressVitePlugin({
4959
repoURL,
5060
contentPath = '',
5161
gitChangelog,
62+
llms = true,
5263
}: NimiqVitepressVitePluginOptions): Plugin[] {
5364
const { resolveId, configureServer, load, transform } = groupIconVitePlugin()
5465

@@ -62,6 +73,12 @@ export function NimiqVitepressVitePlugin({
6273
}
6374
}
6475

76+
// Configure LLMs.txt plugin for automatic llms.txt generation
77+
if (llms !== false) {
78+
const llmsConfig = typeof llms === 'object' ? llms : {}
79+
externalPlugins.push(llmstxt(llmsConfig))
80+
}
81+
6582
// Get project version from package.json
6683
const version = getProjectVersion()
6784

0 commit comments

Comments
 (0)