unplugin-docubook 1.1.3 → 1.2.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 +187 -212
- package/dist/components/index.cjs +1643 -422
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +1590 -422
- package/dist/components/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Universal Documentation Engine for any JavaScript Framework.
|
|
4
4
|
|
|
5
|
-
> Write with MDX — works with pretty much any JS framework:
|
|
5
|
+
> Write with MDX — works with pretty much any JS framework: React, Vue, Svelte, you name it!
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
- 🚀 **Framework Agnostic**: Native support for React, Vue, and Svelte.
|
|
@@ -33,12 +33,198 @@ npm install lucide-vue-next
|
|
|
33
33
|
npm install lucide-svelte
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🔌 Integration
|
|
39
|
+
|
|
40
|
+
DocuBook is not a replacement for your MDX compiler; it is a **transformer** that works alongside your favorite compiler. DocuBook handles automatic component imports (auto-import) before the MDX is compiled.
|
|
41
|
+
|
|
42
|
+
You still need an MDX compiler/bundler based on your framework:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# For Vite (React)
|
|
46
|
+
npm install @mdx-js/rollup @mdx-js/react
|
|
47
|
+
|
|
48
|
+
# For Vite (Vue)
|
|
49
|
+
npm install @mdx-js/rollup @mdx-js/vue
|
|
50
|
+
|
|
51
|
+
# For Next.js
|
|
52
|
+
npm install @next/mdx @mdx-js/loader @mdx-js/react
|
|
53
|
+
|
|
54
|
+
# For Svelte
|
|
55
|
+
npm install mdsvex
|
|
56
|
+
|
|
57
|
+
# For Astro
|
|
58
|
+
npm install @astrojs/mdx
|
|
59
|
+
|
|
60
|
+
# For Nuxt
|
|
61
|
+
npm install @nuxtjs/mdc
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
> [!NOTE]
|
|
65
|
+
> **What's the difference with `next-mdx-remote`?**
|
|
66
|
+
> `next-mdx-remote` compiles MDX at runtime. DocuBook (via Webpack/Vite) processes your MDX files at build-time. If you are using local MDX files, DocuBook eliminates the need to write manual imports in every file or repeatedly register components in a provider.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
> [!TIP]
|
|
71
|
+
> DocuBook supports all major bundlers via `unplugin`. Select your bundler below to see the configuration.
|
|
72
|
+
|
|
73
|
+
<details>
|
|
74
|
+
<summary><b>Vite (React)</b></summary>
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// vite.config.ts
|
|
78
|
+
import { defineConfig } from 'vite';
|
|
79
|
+
import react from '@vitejs/plugin-react';
|
|
80
|
+
import mdx from '@mdx-js/rollup';
|
|
81
|
+
import DocuBook from 'unplugin-docubook/vite';
|
|
82
|
+
|
|
83
|
+
export default defineConfig({
|
|
84
|
+
plugins: [
|
|
85
|
+
react(),
|
|
86
|
+
mdx(),
|
|
87
|
+
DocuBook({
|
|
88
|
+
framework: 'react',
|
|
89
|
+
}),
|
|
90
|
+
],
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
</details>
|
|
94
|
+
|
|
95
|
+
<details>
|
|
96
|
+
<summary><b>Vite (Vue)</b></summary>
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// vite.config.ts
|
|
100
|
+
import { defineConfig } from 'vite';
|
|
101
|
+
import vue from '@vitejs/plugin-vue';
|
|
102
|
+
import mdx from '@mdx-js/rollup';
|
|
103
|
+
import DocuBook from 'unplugin-docubook/vite';
|
|
104
|
+
|
|
105
|
+
export default defineConfig({
|
|
106
|
+
plugins: [
|
|
107
|
+
vue(),
|
|
108
|
+
mdx({ providerImportSource: '@mdx-js/vue' }),
|
|
109
|
+
DocuBook({
|
|
110
|
+
framework: 'vue',
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
</details>
|
|
116
|
+
|
|
117
|
+
<details>
|
|
118
|
+
<summary><b>Next.js (App Router / Pages Router)</b></summary>
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
// next.config.mjs
|
|
122
|
+
import DocuBook from 'unplugin-docubook/webpack';
|
|
123
|
+
import createMDX from '@next/mdx';
|
|
124
|
+
|
|
125
|
+
const withMDX = createMDX({});
|
|
126
|
+
|
|
127
|
+
/** @type {import('next').NextConfig} */
|
|
128
|
+
const nextConfig = {
|
|
129
|
+
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
|
|
130
|
+
webpack(config) {
|
|
131
|
+
config.plugins.push(DocuBook({ framework: 'react' }));
|
|
132
|
+
return config;
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default withMDX(nextConfig);
|
|
137
|
+
```
|
|
138
|
+
</details>
|
|
139
|
+
|
|
140
|
+
<details>
|
|
141
|
+
<summary><b>Svelte (Vite)</b></summary>
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// vite.config.ts
|
|
145
|
+
import { defineConfig } from 'vite';
|
|
146
|
+
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
147
|
+
import mdsvex from 'mdsvex';
|
|
148
|
+
import DocuBook from 'unplugin-docubook/vite';
|
|
149
|
+
|
|
150
|
+
export default defineConfig({
|
|
151
|
+
plugins: [
|
|
152
|
+
svelte({
|
|
153
|
+
extensions: ['.md', '.mdx'],
|
|
154
|
+
}),
|
|
155
|
+
mdsvex({
|
|
156
|
+
extensions: ['.md', '.mdx'],
|
|
157
|
+
}),
|
|
158
|
+
DocuBook({
|
|
159
|
+
framework: 'svelte',
|
|
160
|
+
}),
|
|
161
|
+
],
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
</details>
|
|
165
|
+
|
|
166
|
+
<details>
|
|
167
|
+
<summary><b>Astro</b></summary>
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
// astro.config.mjs
|
|
171
|
+
import { defineConfig } from 'astro/config';
|
|
172
|
+
import mdx from '@astrojs/mdx';
|
|
173
|
+
import DocuBook from 'unplugin-docubook/vite';
|
|
174
|
+
|
|
175
|
+
export default defineConfig({
|
|
176
|
+
integrations: [mdx()],
|
|
177
|
+
vite: {
|
|
178
|
+
plugins: [
|
|
179
|
+
DocuBook({
|
|
180
|
+
framework: 'svelte', // or 'react' if using React in Astro
|
|
181
|
+
}),
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
</details>
|
|
187
|
+
|
|
188
|
+
<details>
|
|
189
|
+
<summary><b>Nuxt (Vue)</b></summary>
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// nuxt.config.ts
|
|
193
|
+
export default defineNuxtConfig({
|
|
194
|
+
modules: ['@nuxtjs/mdc'],
|
|
195
|
+
docubook: {
|
|
196
|
+
framework: 'vue'
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Or use the DocuBook Nuxt module directly:
|
|
202
|
+
```typescript
|
|
203
|
+
// nuxt.config.ts
|
|
204
|
+
export default defineNuxtConfig({
|
|
205
|
+
modules: ['unplugin-docubook/nuxt'],
|
|
206
|
+
docubook: {
|
|
207
|
+
framework: 'vue'
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
```
|
|
211
|
+
</details>
|
|
212
|
+
|
|
213
|
+
<details>
|
|
214
|
+
<summary><b>Webpack / Rollup / Others</b></summary>
|
|
215
|
+
|
|
216
|
+
Import from `unplugin-docubook/webpack` or `unplugin-docubook/rollup` and add to your plugins array.
|
|
217
|
+
</details>
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
36
221
|
## 🎨 Theming & Customization
|
|
37
222
|
|
|
38
223
|
DocuBook uses CSS variables for theming. You can override these variables to customize the appearance of components.
|
|
39
224
|
|
|
40
225
|
### Quick Start
|
|
41
226
|
|
|
227
|
+
> [!NOTE]
|
|
42
228
|
> Import the DocuBook theme in your entry file (`main.ts`, `App.tsx`, etc.)
|
|
43
229
|
|
|
44
230
|
```typescript
|
|
@@ -172,9 +358,6 @@ Override colors for dark mode by adding `.dark` class:
|
|
|
172
358
|
/* ... etc */
|
|
173
359
|
}
|
|
174
360
|
```
|
|
175
|
-
|
|
176
|
-
> [!TIP]
|
|
177
|
-
> DocuBook automatically detects dark mode via the `.dark` class on parent element (compatible with Tailwind CSS).
|
|
178
361
|
</details>
|
|
179
362
|
|
|
180
363
|
<details>
|
|
@@ -228,214 +411,6 @@ DocuBook({
|
|
|
228
411
|
})
|
|
229
412
|
```
|
|
230
413
|
|
|
231
|
-
## 🔌 Integration
|
|
232
|
-
|
|
233
|
-
DocuBook is not a replacement for your MDX compiler; it is a **transformer** that works alongside your favorite compiler. DocuBook handles automatic component imports (auto-import) before the MDX is compiled.
|
|
234
|
-
|
|
235
|
-
### Requirement
|
|
236
|
-
You still need an MDX compiler/bundler based on your framework:
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
# For Vite (React)
|
|
240
|
-
npm install @mdx-js/rollup @mdx-js/react
|
|
241
|
-
|
|
242
|
-
# For Vite (Vue)
|
|
243
|
-
npm install @mdx-js/rollup @mdx-js/vue
|
|
244
|
-
|
|
245
|
-
# For Next.js
|
|
246
|
-
npm install @next/mdx @mdx-js/loader @mdx-js/react
|
|
247
|
-
|
|
248
|
-
# For Svelte
|
|
249
|
-
npm install mdsvex
|
|
250
|
-
|
|
251
|
-
# For Astro
|
|
252
|
-
npm install @astrojs/mdx
|
|
253
|
-
|
|
254
|
-
# For Nuxt
|
|
255
|
-
npm install @nuxtjs/mdc
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
> [!NOTE]
|
|
259
|
-
> **What's the difference with `next-mdx-remote`?**
|
|
260
|
-
> `next-mdx-remote` compiles MDX at runtime. DocuBook (via Webpack/Vite) processes your MDX files at build-time. If you are using local MDX files, DocuBook eliminates the need to write manual imports in every file or repeatedly register components in a provider.
|
|
261
|
-
|
|
262
|
-
---
|
|
263
|
-
|
|
264
|
-
## ⚙️ Configuration
|
|
265
|
-
|
|
266
|
-
> [!TIP]
|
|
267
|
-
> DocuBook supports all major bundlers via `unplugin`. Select your bundler below to see the configuration.
|
|
268
|
-
|
|
269
|
-
<details>
|
|
270
|
-
<summary><b>Vite (React)</b></summary>
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
// vite.config.ts
|
|
274
|
-
import { defineConfig } from 'vite';
|
|
275
|
-
import react from '@vitejs/plugin-react';
|
|
276
|
-
import mdx from '@mdx-js/rollup';
|
|
277
|
-
import DocuBook from 'unplugin-docubook/vite';
|
|
278
|
-
|
|
279
|
-
export default defineConfig({
|
|
280
|
-
plugins: [
|
|
281
|
-
react(),
|
|
282
|
-
mdx(),
|
|
283
|
-
DocuBook({
|
|
284
|
-
framework: 'react',
|
|
285
|
-
}),
|
|
286
|
-
],
|
|
287
|
-
});
|
|
288
|
-
```
|
|
289
|
-
</details>
|
|
290
|
-
|
|
291
|
-
<details>
|
|
292
|
-
<summary><b>Vite (Vue)</b></summary>
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
// vite.config.ts
|
|
296
|
-
import { defineConfig } from 'vite';
|
|
297
|
-
import vue from '@vitejs/plugin-vue';
|
|
298
|
-
import mdx from '@mdx-js/rollup';
|
|
299
|
-
import DocuBook from 'unplugin-docubook/vite';
|
|
300
|
-
|
|
301
|
-
export default defineConfig({
|
|
302
|
-
plugins: [
|
|
303
|
-
vue(),
|
|
304
|
-
mdx({ providerImportSource: '@mdx-js/vue' }),
|
|
305
|
-
DocuBook({
|
|
306
|
-
framework: 'vue',
|
|
307
|
-
}),
|
|
308
|
-
],
|
|
309
|
-
});
|
|
310
|
-
```
|
|
311
|
-
</details>
|
|
312
|
-
|
|
313
|
-
<details>
|
|
314
|
-
<summary><b>Next.js (App Router / Pages Router)</b></summary>
|
|
315
|
-
|
|
316
|
-
First, install the `@next/mdx` compiler:
|
|
317
|
-
```bash
|
|
318
|
-
npm install @next/mdx @mdx-js/loader @mdx-js/react
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
Then configure `next.config.mjs`:
|
|
322
|
-
```javascript
|
|
323
|
-
// next.config.mjs
|
|
324
|
-
import DocuBook from 'unplugin-docubook/webpack';
|
|
325
|
-
import createMDX from '@next/mdx';
|
|
326
|
-
|
|
327
|
-
const withMDX = createMDX({});
|
|
328
|
-
|
|
329
|
-
/** @type {import('next').NextConfig} */
|
|
330
|
-
const nextConfig = {
|
|
331
|
-
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
|
|
332
|
-
webpack(config) {
|
|
333
|
-
config.plugins.push(DocuBook({ framework: 'react' }));
|
|
334
|
-
return config;
|
|
335
|
-
},
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
export default withMDX(nextConfig);
|
|
339
|
-
```
|
|
340
|
-
</details>
|
|
341
|
-
|
|
342
|
-
<details>
|
|
343
|
-
<summary><b>Svelte (Vite)</b></summary>
|
|
344
|
-
|
|
345
|
-
First, install `mdsvex`:
|
|
346
|
-
```bash
|
|
347
|
-
npm install mdsvex
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
Then configure `vite.config.ts`:
|
|
351
|
-
```typescript
|
|
352
|
-
// vite.config.ts
|
|
353
|
-
import { defineConfig } from 'vite';
|
|
354
|
-
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
355
|
-
import mdsvex from 'mdsvex';
|
|
356
|
-
import DocuBook from 'unplugin-docubook/vite';
|
|
357
|
-
|
|
358
|
-
export default defineConfig({
|
|
359
|
-
plugins: [
|
|
360
|
-
svelte({
|
|
361
|
-
extensions: ['.md', '.mdx'],
|
|
362
|
-
}),
|
|
363
|
-
mdsvex({
|
|
364
|
-
extensions: ['.md', '.mdx'],
|
|
365
|
-
}),
|
|
366
|
-
DocuBook({
|
|
367
|
-
framework: 'svelte',
|
|
368
|
-
}),
|
|
369
|
-
],
|
|
370
|
-
});
|
|
371
|
-
```
|
|
372
|
-
</details>
|
|
373
|
-
|
|
374
|
-
<details>
|
|
375
|
-
<summary><b>Astro</b></summary>
|
|
376
|
-
|
|
377
|
-
First, install `@astrojs/mdx`:
|
|
378
|
-
```bash
|
|
379
|
-
npm install @astrojs/mdx
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
Then configure `astro.config.mjs`:
|
|
383
|
-
```javascript
|
|
384
|
-
// astro.config.mjs
|
|
385
|
-
import { defineConfig } from 'astro/config';
|
|
386
|
-
import mdx from '@astrojs/mdx';
|
|
387
|
-
import DocuBook from 'unplugin-docubook/vite';
|
|
388
|
-
|
|
389
|
-
export default defineConfig({
|
|
390
|
-
integrations: [mdx()],
|
|
391
|
-
vite: {
|
|
392
|
-
plugins: [
|
|
393
|
-
DocuBook({
|
|
394
|
-
framework: 'svelte', // or 'react' if using React in Astro
|
|
395
|
-
}),
|
|
396
|
-
],
|
|
397
|
-
},
|
|
398
|
-
});
|
|
399
|
-
```
|
|
400
|
-
</details>
|
|
401
|
-
|
|
402
|
-
<details>
|
|
403
|
-
<summary><b>Nuxt (Vue)</b></summary>
|
|
404
|
-
|
|
405
|
-
First, install `@nuxtjs/mdc`:
|
|
406
|
-
```bash
|
|
407
|
-
npm install @nuxtjs/mdc
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
Then configure `nuxt.config.ts`:
|
|
411
|
-
```typescript
|
|
412
|
-
// nuxt.config.ts
|
|
413
|
-
export default defineNuxtConfig({
|
|
414
|
-
modules: ['@nuxtjs/mdc'],
|
|
415
|
-
docubook: {
|
|
416
|
-
framework: 'vue'
|
|
417
|
-
}
|
|
418
|
-
})
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
Or use the DocuBook Nuxt module directly:
|
|
422
|
-
```typescript
|
|
423
|
-
// nuxt.config.ts
|
|
424
|
-
export default defineNuxtConfig({
|
|
425
|
-
modules: ['unplugin-docubook/nuxt'],
|
|
426
|
-
docubook: {
|
|
427
|
-
framework: 'vue'
|
|
428
|
-
}
|
|
429
|
-
})
|
|
430
|
-
```
|
|
431
|
-
</details>
|
|
432
|
-
|
|
433
|
-
<details>
|
|
434
|
-
<summary><b>Webpack / Rollup / Others</b></summary>
|
|
435
|
-
|
|
436
|
-
Import from `unplugin-docubook/webpack` or `unplugin-docubook/rollup` and add to your plugins array.
|
|
437
|
-
</details>
|
|
438
|
-
|
|
439
414
|
---
|
|
440
415
|
|
|
441
416
|
## License
|