@do11y/docs 0.0.3 → 0.0.5

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.
Files changed (3) hide show
  1. package/README.md +125 -0
  2. package/dist/files.js +1 -0
  3. package/package.json +5 -5
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/dist/files.js CHANGED
@@ -4,5 +4,6 @@ import { searchForWorkspaceRoot } from 'vite';
4
4
  const require = createRequire(import.meta.url);
5
5
  export const ui = join(dirname(require.resolve('@do11y/ui/package.json')));
6
6
  export const root = searchForWorkspaceRoot(process.cwd());
7
+ // export const root = join(searchForWorkspaceRoot(process.cwd()), 'example');
7
8
  export const docs = join(root, 'docs');
8
9
  export const plugins = join(docs, 'site', 'plugins.ts');
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.3",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,7 +24,8 @@
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@vitejs/plugin-vue": "^6.0.2",
27
- "vue": "3.5.25"
27
+ "vue": "3.5.25",
28
+ "vue-router": "^4.6.3"
28
29
  },
29
30
  "dependencies": {
30
31
  "@mdit-vue/plugin-component": "^3.0.2",
@@ -39,7 +40,7 @@
39
40
  "markdown-it-mark": "^4.0.0",
40
41
  "markdown-it-vue-meta": "^0.0.2",
41
42
  "v-custom-block": "^1.0.67",
42
- "@do11y/ui": "0.0.1"
43
+ "@do11y/ui": "0.0.3"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@tsconfig/node24": "^24.0.3",
@@ -47,8 +48,7 @@
47
48
  "@types/markdown-it-attrs": "^4.1.3",
48
49
  "@types/node": "^24.10.1",
49
50
  "typescript": "5.9.3",
50
- "vite": "^7.2.6",
51
- "vue-router": "^4.6.3"
51
+ "vite": "^7.2.6"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "tsc && copyfiles -f src/html/template.html dist/html"