do11y 0.2.14 → 0.2.15

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.
@@ -21,7 +21,7 @@ export const highlightCode = (code, lang) => {
21
21
  transformerNotationErrorLevel(),
22
22
  ...do11yOptions.highlighter.transformers,
23
23
  {
24
- name: "do11y",
24
+ name: "do11y:postprocess",
25
25
  postprocess(html) {
26
26
  if (do11yOptions.highlighter.postprocess) {
27
27
  const jsdom = new JSDOM(html);
@@ -32,7 +32,7 @@ export const highlightCode = (code, lang) => {
32
32
  },
33
33
  },
34
34
  {
35
- name: "remove-unwanted-comments",
35
+ name: "do11y:remove-unwanted-comments",
36
36
  tokens(tokens) {
37
37
  const filter = do11yOptions.highlighter.removeComments;
38
38
  if (filter === false) {
@@ -6,6 +6,11 @@ export interface MarkdownPluginOptions {
6
6
  * Additional markdown-it setup.
7
7
  */
8
8
  markdownSetup?: PluginSimple;
9
+ /**
10
+ * The callback function for rendering code blocks.
11
+ * Will default return the highlighted code generated by Shiki directly.
12
+ */
13
+ renderCodeBlock?: (highlightedCode: string) => string;
9
14
  }
10
15
  export interface MarkdownItEnv {
11
16
  /**
@@ -13,7 +13,8 @@ export default (options) => {
13
13
  const md = markdown({
14
14
  html: true,
15
15
  highlight(code, lang) {
16
- return highlightCode(code, lang);
16
+ const highlightedCode = highlightCode(code, lang);
17
+ return options?.renderCodeBlock ? options.renderCodeBlock(highlightedCode) : highlightedCode;
17
18
  },
18
19
  });
19
20
  md.use(frontmatterPlugin);
@@ -26,7 +26,9 @@ export default () => {
26
26
  const checker = createChecker(tsconfig, {
27
27
  noDeclarations: true,
28
28
  });
29
- const md = markdown();
29
+ const md = markdown({
30
+ html: true,
31
+ });
30
32
  return {
31
33
  name: "do11y:meta",
32
34
  transform(_, id) {
@@ -1,6 +1,6 @@
1
1
  import type { Plugin } from "vite";
2
2
  import type { App, Component } from "vue";
3
- import type { Router } from "vue-router";
3
+ import type { Router, RouteRecordRaw } from "vue-router";
4
4
  import type { BundledTheme, ShikiTransformer, StringLiteralUnion, ThemeInput } from "shiki";
5
5
  import type { MarkdownPluginOptions } from "./markdown.js";
6
6
  export interface Options extends MarkdownPluginOptions {
@@ -28,6 +28,14 @@ export interface Options extends MarkdownPluginOptions {
28
28
  * Custom wrapper component for `.vue.sandbox` imports.
29
29
  */
30
30
  SandboxIframe?: () => Promise<Component>;
31
+ /**
32
+ * Custom additional routes.
33
+ */
34
+ routes?: (RouteRecordRaw & {
35
+ meta: {
36
+ title: string;
37
+ };
38
+ })[];
31
39
  /**
32
40
  * The code highlighter.
33
41
  * - Markdown code blocks
@@ -42,13 +42,25 @@ export default () => {
42
42
  return `
43
43
  import options from 'do11y:options';
44
44
 
45
+ import { RouterView } from 'vue-router';
46
+
45
47
  const home = {
46
48
  path: "/",
47
49
  meta: ${JSON.stringify(homeMeta)},
48
50
  component: options.Home
49
51
  };
50
52
 
51
- export default [home, ${stringifiedRoutes.join(",\n")}];
53
+ const customRoutes = (options.routes ?? []).map(page => ({
54
+ ...page,
55
+
56
+ meta: {
57
+ slug: page.path,
58
+
59
+ ...page.meta,
60
+ }
61
+ }))
62
+
63
+ export default [home, ...customRoutes, ${stringifiedRoutes.join(",\n")}];
52
64
  `;
53
65
  }
54
66
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "do11y",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "A bare-bones tool to document Vue components.",
5
5
  "keywords": [
6
6
  "docs-generator",