do11y 0.5.0 → 0.5.2

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 CHANGED
@@ -9,19 +9,19 @@ A bare-bones tool to document Vue components.
9
9
 
10
10
  ### Markdown components with [@mdit-vue](https://github.com/mdit-vue/mdit-vue).
11
11
 
12
- Markdown files are treated as single file Vue components with the help of [@mdit-vue](https://github.com/mdit-vue/mdit-vue).
12
+ > Customizable through the options `markdownSetup` and `markdownCodeBlock`.
13
13
 
14
- You can customize the markdown-it instance through the `markdownSetup` option.
14
+ Markdown files are treated as single file Vue components with the help of [@mdit-vue](https://github.com/mdit-vue/mdit-vue).
15
15
 
16
- ### Import markdown route files and pages as routes through `do11y:routes`
16
+ ### Markdown routes available through `do11y:routes`
17
17
 
18
- To include a markdown file as a route it needs to have a `title` and a `slug` (e.g. `/button`) in it's frontmatter. Or add it inside the `docs/do11y/pages` folder.
18
+ To include a markdown file as a route it needs to have a `title` and a `slug` (e.g. `/button`) in it's frontmatter, or it needs to be placed inside `docs/do11y/pages`.
19
19
 
20
20
  ### [Shiki](https://shiki.style) code highlighting
21
21
 
22
- Code blocks are automatically highlighted with [Shiki](https://shiki.style).
22
+ > Customizable through the `highlighter` option.
23
23
 
24
- You can customize the Shiki instance through the `highlighter` options.
24
+ Code blocks are automatically highlighted with [Shiki](https://shiki.style).
25
25
 
26
26
  ### Highlight imports
27
27
 
@@ -30,28 +30,50 @@ You can import Vue files as highlighted code blocks through `.vue?highlight`, or
30
30
  These imports return HTML strings meaning you have to render the code block using `v-html`.
31
31
 
32
32
  > [!WARNING]
33
- > Imports of type `.vue?highlight&lang=css` only work on built sites. During development it will return the same result as `.vue?highlight`.
33
+ > Imports of type `.vue?highlight&lang=css` only work on _built_ sites. During development it will return the same result as `.vue?highlight`.
34
34
 
35
35
  ### Sandboxes
36
36
 
37
- Create sandbox components - e.g. `Button.sandbox.vue` will be available under the url `/sandbox?id=button`, and if importing the component it will be wrapped inside an iframe component that has access to the components `?highlight` imports.
37
+ > To customize the Sandbox app add a custom `docs/do11y/pages/Sandbox.vue` wrapper component and/or use the `setupSandbox` option.
38
38
 
39
- To customize the sandbox app, use the `Sandbox` option - and to cutomize the iframe component used for import, use the `SandboxIframe` option.
39
+ Turn a component into a sandbox by adding a `.sandbox` prefix to the component name, e.g. `Button.sandbox.vue` will be available under the url `/sandbox?id=button`, and when importing the component it will be wrapped inside an iframe.
40
40
 
41
41
  > [!NOTE]
42
- > The id is based on the filename - not the path to the file - this means if you have two sandbox files of the same name in different locations - they won't both work.
42
+ > The id of a sandbox component is based on the filename - not the path - this means every sandbox component must have a unique name.
43
+
44
+ #### Sandbox Iframe
45
+
46
+ > To customize the Sandbox app add a custom `docs/do11y/layout/SandboxIframe.vue` wrapper component.
47
+
48
+ The sandbox iframe component has some props automatically passed to it - you can use the `SandboxIframeProps` type to declare these.
49
+
50
+ ```vue
51
+ <template>
52
+ <iframe ref="iframe" :title="`Sandbox for ${title || id}`" :src="url" />
53
+ </template>
54
+
55
+ <script lang="ts" setup>
56
+ import type { SandboxIframeProps } from "do11y";
57
+
58
+ defineProps<SandboxIframeProps & { title?: string }>();
59
+ </script>
60
+ ```
43
61
 
44
62
  ### Document components with [vue-component-meta](https://www.npmjs.com/package/vue-component-meta)
45
63
 
46
- Document components through meta imports (`Button.vue?meta`) which give a simplified version of a result from [vue-component-meta](https://www.npmjs.com/package/vue-component-meta).
64
+ Document components through meta imports (`Button.vue?meta`) which give a simplified version of the result from [vue-component-meta](https://www.npmjs.com/package/vue-component-meta).
47
65
 
48
66
  ## Options
49
67
 
50
- Expected as the default export in `docs/do11y/do11y.ts`.
68
+ > Options should be the default export of `docs/do11y/do11y.ts`.
51
69
 
52
- You can specify a layout for each page by adding a `docs/do11y/layout/Page.vue` file with a `<RouterView />` in it.
70
+ You can set the home page by adding a `docs/do11y/pages/Home.vue` file, and you can add a layout for each page in `docs/do11y/layout/Page.vue` using `<RouterView />`.
53
71
 
54
- And you can set the home page by adding `docs/do11y/pages/Home.vue`.
72
+ ```ts
73
+ import type { Options } from "do11y";
74
+
75
+ export default {} satisfies Options;
76
+ ```
55
77
 
56
78
  ```ts
57
79
  interface Options {
@@ -60,21 +82,11 @@ interface Options {
60
82
  */
61
83
  setup?(app: App, router: Router): void | Promise<void>;
62
84
 
63
- /**
64
- * The wrapper component for sandboxes.
65
- */
66
- Sandbox?: () => Promise<Component>;
67
-
68
85
  /**
69
86
  * Additional setup for the sandbox app.
70
87
  */
71
88
  setupSandbox?(app: App): void | Promise<void>;
72
89
 
73
- /**
74
- * Custom wrapper component for `.vue.sandbox` imports.
75
- */
76
- SandboxIframe?: () => Promise<Component>;
77
-
78
90
  /**
79
91
  * The code highlighter.
80
92
  * - Markdown code blocks
@@ -23,6 +23,9 @@ export default () => {
23
23
  return {
24
24
  name: "do11y:options",
25
25
  async resolveId(id, importer) {
26
+ if (id === "do11y:options") {
27
+ return this.resolve(setupFiles[id], importer);
28
+ }
26
29
  if (Object.keys(setupFiles).includes(id)) {
27
30
  /* prettier-ignore */
28
31
  return existsSync(setupFiles[id])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "do11y",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "A bare-bones tool to document Vue components.",
5
5
  "keywords": [
6
6
  "docs-generator",