@nuxtjs/mdc 0.19.1 → 0.19.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
@@ -128,14 +128,14 @@ export default defineNuxtConfig({
128
128
  components: {
129
129
  prose: false, // Disable predefined prose components
130
130
  map: {
131
- p: 'MyCustomPComponent'
131
+ p: 'MyCustomPComponent' // add global like MyCustomPComponent.global.vue
132
132
  }
133
133
  }
134
134
  }
135
135
  })
136
136
  ```
137
137
 
138
- In order to customize these components yourself simply make a component with the same name of the prose component you are trying to take control over. Make sure to put these prose components in their own prose folder and tell nuxt to globally register them so that MDC can get proper access.
138
+ In order to customize these components yourself simply make a component with the same name of the prose component you are trying to take control over. Make sure to put these prose components in their own prose folder and tell nuxt to globally register or simple create in `prose` folder `P.global.vue` them so that MDC can get proper access.
139
139
 
140
140
  ```ts
141
141
  export default defineNuxtConfig({
package/dist/module.d.mts CHANGED
@@ -574,6 +574,7 @@ declare module '@nuxt/schema' {
574
574
  map: Record<string, string>;
575
575
  };
576
576
  headings: ModuleOptions['headings'];
577
+ highlight: ModuleOptions['highlight'];
577
578
  };
578
579
  }
579
580
  interface ConfigSchema {
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
3
  "configKey": "mdc",
4
- "version": "0.19.1",
4
+ "version": "0.19.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -84,7 +84,7 @@ async function mdcHighlighter({
84
84
  }
85
85
  code = code.replace(
86
86
  /from\s+(['"])shiki\1/,
87
- 'from "shiki/engine/javascript"'
87
+ 'from "@shikijs/engine-javascript"'
88
88
  );
89
89
  const langsMap = /* @__PURE__ */ new Map();
90
90
  options.langs?.forEach((lang) => {
@@ -110,7 +110,7 @@ async function mdcHighlighter({
110
110
  } = options;
111
111
  return [
112
112
  "import { getMdcConfigs } from '#mdc-configs'",
113
- shikiEngine === "javascript" ? "" : "import { createOnigurumaEngine } from 'shiki/engine/oniguruma'",
113
+ shikiEngine === "javascript" ? "" : "import { createOnigurumaEngine } from '@shikijs/engine-oniguruma'",
114
114
  code,
115
115
  "const bundledLangs = {",
116
116
  ...Array.from(langsMap.entries()).map(([name, lang]) => typeof lang === "string" ? JSON.stringify(name) + `: () => import('@shikijs/langs/${lang}').then(r => r.default || r),` : JSON.stringify(name) + ": " + JSON.stringify(lang) + ","),
@@ -263,7 +263,8 @@ const module$1 = defineNuxtModule({
263
263
  prose: options.components.prose,
264
264
  map: options.components.map
265
265
  },
266
- headings: options.headings
266
+ headings: options.headings,
267
+ highlight: options.highlight
267
268
  });
268
269
  nuxt.options.build.transpile ||= [];
269
270
  nuxt.options.build.transpile.push("yaml");
@@ -12,14 +12,14 @@ type __VLS_Slots = {} & {
12
12
  };
13
13
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
14
  tag: {
15
- type: (BooleanConstructor | StringConstructor)[];
15
+ type: (StringConstructor | BooleanConstructor)[];
16
16
  default: string;
17
17
  };
18
18
  /**
19
19
  * Raw markdown string or parsed markdown object from `parseMarkdown`
20
20
  */
21
21
  value: {
22
- type: (ObjectConstructor | StringConstructor)[];
22
+ type: (StringConstructor | ObjectConstructor)[];
23
23
  required: true;
24
24
  };
25
25
  /**
@@ -40,7 +40,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
40
40
  * Class to be applied to the root element
41
41
  */
42
42
  class: {
43
- type: (ObjectConstructor | ArrayConstructor | StringConstructor)[];
43
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
44
44
  default: string;
45
45
  };
46
46
  /**
@@ -48,7 +48,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
48
48
  * Example: 'ul li'
49
49
  */
50
50
  unwrap: {
51
- type: (BooleanConstructor | StringConstructor)[];
51
+ type: (StringConstructor | BooleanConstructor)[];
52
52
  default: boolean;
53
53
  };
54
54
  /**
@@ -68,14 +68,14 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
68
68
  };
69
69
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
70
70
  tag: {
71
- type: (BooleanConstructor | StringConstructor)[];
71
+ type: (StringConstructor | BooleanConstructor)[];
72
72
  default: string;
73
73
  };
74
74
  /**
75
75
  * Raw markdown string or parsed markdown object from `parseMarkdown`
76
76
  */
77
77
  value: {
78
- type: (ObjectConstructor | StringConstructor)[];
78
+ type: (StringConstructor | ObjectConstructor)[];
79
79
  required: true;
80
80
  };
81
81
  /**
@@ -96,7 +96,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
96
96
  * Class to be applied to the root element
97
97
  */
98
98
  class: {
99
- type: (ObjectConstructor | ArrayConstructor | StringConstructor)[];
99
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
100
100
  default: string;
101
101
  };
102
102
  /**
@@ -104,7 +104,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
104
104
  * Example: 'ul li'
105
105
  */
106
106
  unwrap: {
107
- type: (BooleanConstructor | StringConstructor)[];
107
+ type: (StringConstructor | BooleanConstructor)[];
108
108
  default: boolean;
109
109
  };
110
110
  /**
@@ -126,7 +126,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
126
126
  tag: string | boolean;
127
127
  excerpt: boolean;
128
128
  parserOptions: MDCParseOptions;
129
- class: string | Record<string, any> | unknown[];
129
+ class: string | unknown[] | Record<string, any>;
130
130
  unwrap: string | boolean;
131
131
  cacheKey: string;
132
132
  partial: boolean;
@@ -12,14 +12,14 @@ type __VLS_Slots = {} & {
12
12
  };
13
13
  declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
14
14
  tag: {
15
- type: (BooleanConstructor | StringConstructor)[];
15
+ type: (StringConstructor | BooleanConstructor)[];
16
16
  default: string;
17
17
  };
18
18
  /**
19
19
  * Raw markdown string or parsed markdown object from `parseMarkdown`
20
20
  */
21
21
  value: {
22
- type: (ObjectConstructor | StringConstructor)[];
22
+ type: (StringConstructor | ObjectConstructor)[];
23
23
  required: true;
24
24
  };
25
25
  /**
@@ -40,7 +40,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
40
40
  * Class to be applied to the root element
41
41
  */
42
42
  class: {
43
- type: (ObjectConstructor | ArrayConstructor | StringConstructor)[];
43
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
44
44
  default: string;
45
45
  };
46
46
  /**
@@ -48,7 +48,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
48
48
  * Example: 'ul li'
49
49
  */
50
50
  unwrap: {
51
- type: (BooleanConstructor | StringConstructor)[];
51
+ type: (StringConstructor | BooleanConstructor)[];
52
52
  default: boolean;
53
53
  };
54
54
  /**
@@ -75,14 +75,14 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
75
75
  };
76
76
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
77
77
  tag: {
78
- type: (BooleanConstructor | StringConstructor)[];
78
+ type: (StringConstructor | BooleanConstructor)[];
79
79
  default: string;
80
80
  };
81
81
  /**
82
82
  * Raw markdown string or parsed markdown object from `parseMarkdown`
83
83
  */
84
84
  value: {
85
- type: (ObjectConstructor | StringConstructor)[];
85
+ type: (StringConstructor | ObjectConstructor)[];
86
86
  required: true;
87
87
  };
88
88
  /**
@@ -103,7 +103,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
103
103
  * Class to be applied to the root element
104
104
  */
105
105
  class: {
106
- type: (ObjectConstructor | ArrayConstructor | StringConstructor)[];
106
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
107
107
  default: string;
108
108
  };
109
109
  /**
@@ -111,7 +111,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
111
111
  * Example: 'ul li'
112
112
  */
113
113
  unwrap: {
114
- type: (BooleanConstructor | StringConstructor)[];
114
+ type: (StringConstructor | BooleanConstructor)[];
115
115
  default: boolean;
116
116
  };
117
117
  /**
@@ -140,7 +140,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
140
140
  tag: string | boolean;
141
141
  excerpt: boolean;
142
142
  parserOptions: MDCParseOptions;
143
- class: string | Record<string, any> | unknown[];
143
+ class: string | unknown[] | Record<string, any>;
144
144
  unwrap: string | boolean;
145
145
  cacheKey: string;
146
146
  partial: boolean;
@@ -1,5 +1,7 @@
1
1
  import type { PropType, DefineComponent } from 'vue';
2
2
  import type { MDCRoot } from '@nuxtjs/mdc';
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
3
5
  declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
4
6
  /**
5
7
  * Content to render
@@ -19,14 +21,14 @@ declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
19
21
  * Class(es) to bind to the component
20
22
  */
21
23
  class: {
22
- type: (ObjectConstructor | StringConstructor)[];
24
+ type: (StringConstructor | ObjectConstructor)[];
23
25
  default: undefined;
24
26
  };
25
27
  /**
26
28
  * Root tag to use for rendering
27
29
  */
28
30
  tag: {
29
- type: (BooleanConstructor | StringConstructor)[];
31
+ type: (StringConstructor | BooleanConstructor)[];
30
32
  default: undefined;
31
33
  };
32
34
  /**
@@ -48,7 +50,7 @@ declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
48
50
  * Example: 'ul li'
49
51
  */
50
52
  unwrap: {
51
- type: (BooleanConstructor | StringConstructor)[];
53
+ type: (StringConstructor | BooleanConstructor)[];
52
54
  default: boolean;
53
55
  };
54
56
  }>, {
@@ -80,14 +82,14 @@ declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
80
82
  * Class(es) to bind to the component
81
83
  */
82
84
  class: {
83
- type: (ObjectConstructor | StringConstructor)[];
85
+ type: (StringConstructor | ObjectConstructor)[];
84
86
  default: undefined;
85
87
  };
86
88
  /**
87
89
  * Root tag to use for rendering
88
90
  */
89
91
  tag: {
90
- type: (BooleanConstructor | StringConstructor)[];
92
+ type: (StringConstructor | BooleanConstructor)[];
91
93
  default: undefined;
92
94
  };
93
95
  /**
@@ -109,16 +111,14 @@ declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
109
111
  * Example: 'ul li'
110
112
  */
111
113
  unwrap: {
112
- type: (BooleanConstructor | StringConstructor)[];
114
+ type: (StringConstructor | BooleanConstructor)[];
113
115
  default: boolean;
114
116
  };
115
117
  }>> & Readonly<{}>, {
116
- data: Record<string, any>;
117
118
  tag: string | boolean;
118
119
  class: string | Record<string, any>;
119
120
  unwrap: string | boolean;
121
+ data: Record<string, any>;
120
122
  components: Record<string, string | DefineComponent<any, any, any>>;
121
123
  prose: boolean;
122
124
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
123
- declare const _default: typeof __VLS_export;
124
- export default _default;
@@ -1,4 +1,9 @@
1
1
  import type { Slot } from 'vue';
2
+ /**
3
+ * MDCSlot component
4
+ */
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
2
7
  declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
8
  name: {
4
9
  type: StringConstructor;
@@ -9,7 +14,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
9
14
  * Example: 'ul li'
10
15
  */
11
16
  unwrap: {
12
- type: (BooleanConstructor | StringConstructor)[];
17
+ type: (StringConstructor | BooleanConstructor)[];
13
18
  default: boolean;
14
19
  };
15
20
  /**
@@ -34,7 +39,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
34
39
  * Example: 'ul li'
35
40
  */
36
41
  unwrap: {
37
- type: (BooleanConstructor | StringConstructor)[];
42
+ type: (StringConstructor | BooleanConstructor)[];
38
43
  default: boolean;
39
44
  };
40
45
  /**
@@ -46,12 +51,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
46
51
  default: undefined;
47
52
  };
48
53
  }>> & Readonly<{}>, {
49
- name: string;
50
54
  unwrap: string | boolean;
55
+ name: string;
51
56
  use: Function;
52
57
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
53
- /**
54
- * MDCSlot component
55
- */
56
- declare const _default: typeof __VLS_export;
57
- export default _default;
@@ -8,11 +8,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
8
8
  default: string;
9
9
  };
10
10
  width: {
11
- type: (NumberConstructor | StringConstructor)[];
11
+ type: (StringConstructor | NumberConstructor)[];
12
12
  default: undefined;
13
13
  };
14
14
  height: {
15
- type: (NumberConstructor | StringConstructor)[];
15
+ type: (StringConstructor | NumberConstructor)[];
16
16
  default: undefined;
17
17
  };
18
18
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -25,11 +25,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
25
25
  default: string;
26
26
  };
27
27
  width: {
28
- type: (NumberConstructor | StringConstructor)[];
28
+ type: (StringConstructor | NumberConstructor)[];
29
29
  default: undefined;
30
30
  };
31
31
  height: {
32
- type: (NumberConstructor | StringConstructor)[];
32
+ type: (StringConstructor | NumberConstructor)[];
33
33
  default: undefined;
34
34
  };
35
35
  }>> & Readonly<{}>, {
@@ -1,4 +1,16 @@
1
1
  import { rehypeHighlight as rehypeHighlightUniversal } from "./rehype.js";
2
+ import { useRuntimeConfig } from "#imports";
3
+ class HighlighterError extends Error {
4
+ constructor(message, httpStatus) {
5
+ super(message);
6
+ this.httpStatus = httpStatus;
7
+ this.name = "HighlighterError";
8
+ }
9
+ }
10
+ function isHighlightResult(res) {
11
+ if (!res) return false;
12
+ return "tree" in res;
13
+ }
2
14
  const defaults = {
3
15
  theme: {},
4
16
  async highlighter(code, lang, theme, options) {
@@ -6,7 +18,16 @@ const defaults = {
6
18
  if (import.meta.client && window.sessionStorage.getItem("mdc-shiki-highlighter") === "browser") {
7
19
  return import("#mdc-highlighter").then((h) => h.default(code, lang, theme, options)).catch(() => ({}));
8
20
  }
9
- return await $fetch("/api/_mdc/highlight", {
21
+ if (import.meta.client) {
22
+ const highlight = useRuntimeConfig().public.mdc.highlight;
23
+ if (highlight === false) {
24
+ return Promise.resolve({ tree: [{ type: "text", value: code }], className: "", style: "" });
25
+ }
26
+ if (highlight?.noApiRoute === true) {
27
+ return import("#mdc-highlighter").then((h) => h.default(code, lang, theme, options)).catch(() => ({}));
28
+ }
29
+ }
30
+ const result = await $fetch("/api/_mdc/highlight", {
10
31
  params: {
11
32
  code,
12
33
  lang,
@@ -14,8 +35,12 @@ const defaults = {
14
35
  options: JSON.stringify(options)
15
36
  }
16
37
  });
38
+ if (!isHighlightResult(result)) {
39
+ throw new HighlighterError(`result:${result}`);
40
+ }
41
+ return result;
17
42
  } catch (e) {
18
- if (import.meta.client && e?.response?.status === 404) {
43
+ if (import.meta.client && (e?.response?.status > 399 || e?.name == "HighlighterError")) {
19
44
  window.sessionStorage.setItem("mdc-shiki-highlighter", "browser");
20
45
  return this.highlighter?.(code, lang, theme, options);
21
46
  }
@@ -1,4 +1,4 @@
1
- import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
1
+ import { createJavaScriptRegexEngine } from "@shikijs/engine-javascript";
2
2
  export function createShikiHighlighter({
3
3
  langs = [],
4
4
  themes = [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "description": "Nuxt MDC module",
5
5
  "repository": "nuxt-content/mdc",
6
6
  "license": "MIT",
@@ -68,14 +68,14 @@
68
68
  "verify": "npm run dev:prepare && npm run lint && npm run test && npm run typecheck"
69
69
  },
70
70
  "dependencies": {
71
- "@nuxt/kit": "^4.2.1",
72
- "@shikijs/core": "^3.17.0",
73
- "@shikijs/langs": "^3.17.0",
74
- "@shikijs/themes": "^3.17.0",
75
- "@shikijs/transformers": "^3.17.0",
71
+ "@nuxt/kit": "^4.2.2",
72
+ "@shikijs/core": "^3.20.0",
73
+ "@shikijs/langs": "^3.20.0",
74
+ "@shikijs/themes": "^3.20.0",
75
+ "@shikijs/transformers": "^3.20.0",
76
76
  "@types/hast": "^3.0.4",
77
77
  "@types/mdast": "^4.0.4",
78
- "@vue/compiler-core": "^3.5.25",
78
+ "@vue/compiler-core": "^3.5.26",
79
79
  "consola": "^3.4.2",
80
80
  "debug": "^4.4.3",
81
81
  "defu": "^6.1.4",
@@ -99,40 +99,40 @@
99
99
  "rehype-sort-attributes": "^5.0.1",
100
100
  "remark-emoji": "^5.0.2",
101
101
  "remark-gfm": "^4.0.1",
102
- "remark-mdc": "^3.9.0",
102
+ "remark-mdc": "^3.10.0",
103
103
  "remark-parse": "^11.0.0",
104
104
  "remark-rehype": "^11.1.2",
105
105
  "remark-stringify": "^11.0.0",
106
106
  "scule": "^1.3.0",
107
- "shiki": "^3.17.0",
107
+ "shiki": "^3.20.0",
108
108
  "ufo": "^1.6.1",
109
109
  "unified": "^11.0.5",
110
110
  "unist-builder": "^4.0.0",
111
111
  "unist-util-visit": "^5.0.0",
112
- "unwasm": "^0.5.0",
112
+ "unwasm": "^0.5.2",
113
113
  "vfile": "^6.0.3"
114
114
  },
115
115
  "devDependencies": {
116
116
  "@nuxt/devtools": "^3.1.1",
117
- "@nuxt/eslint-config": "^1.11.0",
117
+ "@nuxt/eslint-config": "^1.12.1",
118
118
  "@nuxt/module-builder": "^1.0.2",
119
- "@nuxt/schema": "^4.2.1",
120
- "@nuxt/test-utils": "^3.20.1",
121
- "@nuxt/ui": "^4.2.1",
119
+ "@nuxt/schema": "^4.2.2",
120
+ "@nuxt/test-utils": "^3.21.0",
121
+ "@nuxt/ui": "^4.3.0",
122
122
  "@nuxtjs/mdc": "link:.",
123
- "@types/node": "^24.10.1",
124
- "eslint": "^9.39.1",
125
- "nuxt": "^4.2.1",
123
+ "@types/node": "^25.0.3",
124
+ "eslint": "^9.39.2",
125
+ "nuxt": "^4.2.2",
126
126
  "rehype": "^13.0.2",
127
- "release-it": "^19.0.6",
127
+ "release-it": "^19.2.1",
128
128
  "typescript": "5.9.3",
129
- "vitest": "^4.0.14",
130
- "vue-tsc": "^3.1.5"
129
+ "vitest": "^4.0.16",
130
+ "vue-tsc": "^3.2.1"
131
131
  },
132
132
  "resolutions": {
133
133
  "mkdist": "2.3.0"
134
134
  },
135
- "packageManager": "pnpm@10.24.0",
135
+ "packageManager": "pnpm@10.26.2",
136
136
  "release-it": {
137
137
  "git": {
138
138
  "commitMessage": "chore(release): release v${version}"