@do11y/docs 0.0.3 → 0.0.4
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 +125 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# @do11y/docs
|
|
2
|
+
|
|
3
|
+
A very bare-bones tool to help document Vue components.
|
|
4
|
+
|
|
5
|
+
- Write documentation in Markdown files that get treated as Vue components
|
|
6
|
+
- Import markdown files with a `title` and `slug` added through frontmatter as routes
|
|
7
|
+
- Sandbox components - e.g. `Button.sandbox.vue` will be available on the url `/sandbox?id=button`
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i @do11y/docs
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
### Allow markdown files in `vite.config.ts` file
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
21
|
+
|
|
22
|
+
import { defineConfig } from 'vite';
|
|
23
|
+
|
|
24
|
+
import vue from '@vitejs/plugin-vue';
|
|
25
|
+
import vueDevTools from 'vite-plugin-vue-devtools';
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
plugins: [vue({ include: [/\.vue$/, /\.md$/] }), vueDevTools()],
|
|
29
|
+
|
|
30
|
+
resolve: {
|
|
31
|
+
alias: {
|
|
32
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Add scripts to `package.json`
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"scripts": {
|
|
43
|
+
"docs:dev": "do11y",
|
|
44
|
+
"docs:build": "do11y build",
|
|
45
|
+
"docs:preview": "do11y preview"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Add the `docs` folder
|
|
51
|
+
|
|
52
|
+
#### Add `tsconfig.json` file
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"extends": "../tsconfig.json",
|
|
57
|
+
"include": ["site/**/*", "../src/**/*"],
|
|
58
|
+
|
|
59
|
+
"compilerOptions": {
|
|
60
|
+
"types": ["@do11y/docs/types"]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Add a `site/index.ts` file
|
|
66
|
+
|
|
67
|
+
This file will be used to configure the documentation site. The configuration requires you to pass an import for the main `Site` component.
|
|
68
|
+
|
|
69
|
+
> [!WARNING]
|
|
70
|
+
> Both the documentation site and the sandbox uses the same `setup` function. This means importing styles or components directly in this file will also import them to the sandbox.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import type { Site } from '@do11y/docs';
|
|
74
|
+
|
|
75
|
+
export default {
|
|
76
|
+
Site: () => import('./Site.vue'),
|
|
77
|
+
|
|
78
|
+
setup(app) {
|
|
79
|
+
// App setup
|
|
80
|
+
},
|
|
81
|
+
} satisfies Site;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Add a `site/plugins.ts` file
|
|
85
|
+
|
|
86
|
+
This file will be used to configure the different plugins available.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import type { PluginOptions } from '@do11y/docs';
|
|
90
|
+
|
|
91
|
+
export default {
|
|
92
|
+
metaRenderer(meta, title) {
|
|
93
|
+
return `
|
|
94
|
+
<h3>${title}</h3>
|
|
95
|
+
<pre><code>${JSON.stringify(meta, null, 2)}</code></pre>
|
|
96
|
+
`;
|
|
97
|
+
},
|
|
98
|
+
} satisfies PluginOptions;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Add a main `Site` component
|
|
102
|
+
|
|
103
|
+
Inside the app you can import the available routes from `dolly:routes`.
|
|
104
|
+
|
|
105
|
+
```vue
|
|
106
|
+
<template>
|
|
107
|
+
<nav>
|
|
108
|
+
<ul>
|
|
109
|
+
<template v-for="route of routes" :key="route.path">
|
|
110
|
+
<li>
|
|
111
|
+
<router-link :to="route.path">
|
|
112
|
+
{{ route.meta.title }}
|
|
113
|
+
</router-link>
|
|
114
|
+
</li>
|
|
115
|
+
</template>
|
|
116
|
+
</ul>
|
|
117
|
+
</nav>
|
|
118
|
+
|
|
119
|
+
<RouterView />
|
|
120
|
+
</template>
|
|
121
|
+
|
|
122
|
+
<script lang="ts" setup>
|
|
123
|
+
import routes from 'do11y:routes';
|
|
124
|
+
</script>
|
|
125
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@do11y/docs",
|
|
3
3
|
"description": "A very bare-bones tool to help document Vue components.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"markdown-it-mark": "^4.0.0",
|
|
40
40
|
"markdown-it-vue-meta": "^0.0.2",
|
|
41
41
|
"v-custom-block": "^1.0.67",
|
|
42
|
-
"@do11y/ui": "0.0.
|
|
42
|
+
"@do11y/ui": "0.0.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@tsconfig/node24": "^24.0.3",
|