@nuxtjs/mdc 0.7.0 → 0.7.1

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/dist/config.d.mts CHANGED
@@ -1,48 +1,4 @@
1
- import { Highlighter, ShikiTransformer, HighlighterCore } from 'shiki';
2
- import { Processor } from 'unified';
3
- import { M as MdcThemeOptions, H as HighlighterOptions } from './shared/mdc.a6f76af4.mjs';
4
-
5
- type Awaitable<T> = T | Promise<T>;
6
- interface MdcConfig {
7
- /**
8
- * Hooks for the unified markdown pipeline
9
- */
10
- unified?: {
11
- /**
12
- * Custom setup for unified processor before other plugins
13
- */
14
- pre?: (processor: Processor) => Awaitable<void | Processor>;
15
- /**
16
- * Custom setup for unified processor after remark but before rehype
17
- */
18
- remark?: (processor: Processor) => Awaitable<void | Processor>;
19
- /**
20
- * Custom setup for unified processor after rehype
21
- */
22
- rehype?: (processor: Processor) => Awaitable<void | Processor>;
23
- /**
24
- * Custom setup for unified processor after all plugins
25
- */
26
- post?: (processor: Processor) => Awaitable<void | Processor>;
27
- };
28
- /**
29
- * Custom hightlighter, available when `highlighter` is set to `custom`
30
- */
31
- highlighter?: Highlighter;
32
- /**
33
- * Hooks for shiki
34
- */
35
- shiki?: {
36
- /**
37
- * Get transformers for shiki
38
- */
39
- transformers?: ShikiTransformer[] | ((code: string, lang: string, theme: MdcThemeOptions, options: Partial<HighlighterOptions>) => Awaitable<ShikiTransformer[]>);
40
- /**
41
- * Custom setup for shiki instance, only called once on server or client
42
- */
43
- setup?: (highlighter: HighlighterCore) => Awaitable<void>;
44
- };
45
- }
1
+ import { MdcConfig } from './runtime/types/config.ts';
46
2
 
47
3
  declare function defineConfig(config: MdcConfig): MdcConfig;
48
4
 
package/dist/config.d.ts CHANGED
@@ -1,48 +1,4 @@
1
- import { Highlighter, ShikiTransformer, HighlighterCore } from 'shiki';
2
- import { Processor } from 'unified';
3
- import { M as MdcThemeOptions, H as HighlighterOptions } from './shared/mdc.a6f76af4.js';
4
-
5
- type Awaitable<T> = T | Promise<T>;
6
- interface MdcConfig {
7
- /**
8
- * Hooks for the unified markdown pipeline
9
- */
10
- unified?: {
11
- /**
12
- * Custom setup for unified processor before other plugins
13
- */
14
- pre?: (processor: Processor) => Awaitable<void | Processor>;
15
- /**
16
- * Custom setup for unified processor after remark but before rehype
17
- */
18
- remark?: (processor: Processor) => Awaitable<void | Processor>;
19
- /**
20
- * Custom setup for unified processor after rehype
21
- */
22
- rehype?: (processor: Processor) => Awaitable<void | Processor>;
23
- /**
24
- * Custom setup for unified processor after all plugins
25
- */
26
- post?: (processor: Processor) => Awaitable<void | Processor>;
27
- };
28
- /**
29
- * Custom hightlighter, available when `highlighter` is set to `custom`
30
- */
31
- highlighter?: Highlighter;
32
- /**
33
- * Hooks for shiki
34
- */
35
- shiki?: {
36
- /**
37
- * Get transformers for shiki
38
- */
39
- transformers?: ShikiTransformer[] | ((code: string, lang: string, theme: MdcThemeOptions, options: Partial<HighlighterOptions>) => Awaitable<ShikiTransformer[]>);
40
- /**
41
- * Custom setup for shiki instance, only called once on server or client
42
- */
43
- setup?: (highlighter: HighlighterCore) => Awaitable<void>;
44
- };
45
- }
1
+ import { MdcConfig } from './runtime/types/config.ts';
46
2
 
47
3
  declare function defineConfig(config: MdcConfig): MdcConfig;
48
4
 
package/dist/module.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { BundledLanguage, LanguageRegistration, BundledTheme, ThemeRegistrationAny } from 'shiki';
3
- import { M as MdcThemeOptions } from './shared/mdc.a6f76af4.mjs';
3
+ import { MdcThemeOptions } from './runtime/highlighter/types.ts';
4
4
 
5
5
  interface UnistPlugin {
6
6
  src?: string;
@@ -37,7 +37,7 @@ interface ModuleOptions {
37
37
  *
38
38
  * Unlike the `preload` option, when this option is provided, it will override the default languages.
39
39
  *
40
- * @default ['js','jsx','json','ts','tsx','vue','css','html','vue','bash','md','mdc','yaml']
40
+ * @default ['js','jsx','json','ts','tsx','vue','css','html','bash','md','mdc','yaml']
41
41
  */
42
42
  langs?: (BundledLanguage | LanguageRegistration)[];
43
43
  /**
@@ -60,7 +60,7 @@ interface ModuleOptions {
60
60
  headings?: {
61
61
  anchorLinks?: {
62
62
  [heading in 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6']?: boolean;
63
- };
63
+ } | false;
64
64
  };
65
65
  keepComments?: boolean;
66
66
  components?: {
@@ -83,6 +83,7 @@ declare module '@nuxt/schema' {
83
83
  map: Record<string, string>;
84
84
  };
85
85
  headings: ModuleOptions['headings'];
86
+ useNuxtImage?: boolean;
86
87
  };
87
88
  }
88
89
  interface ConfigSchema {
package/dist/module.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { BundledLanguage, LanguageRegistration, BundledTheme, ThemeRegistrationAny } from 'shiki';
3
- import { M as MdcThemeOptions } from './shared/mdc.a6f76af4.js';
3
+ import { MdcThemeOptions } from './runtime/highlighter/types.ts';
4
4
 
5
5
  interface UnistPlugin {
6
6
  src?: string;
@@ -37,7 +37,7 @@ interface ModuleOptions {
37
37
  *
38
38
  * Unlike the `preload` option, when this option is provided, it will override the default languages.
39
39
  *
40
- * @default ['js','jsx','json','ts','tsx','vue','css','html','vue','bash','md','mdc','yaml']
40
+ * @default ['js','jsx','json','ts','tsx','vue','css','html','bash','md','mdc','yaml']
41
41
  */
42
42
  langs?: (BundledLanguage | LanguageRegistration)[];
43
43
  /**
@@ -60,7 +60,7 @@ interface ModuleOptions {
60
60
  headings?: {
61
61
  anchorLinks?: {
62
62
  [heading in 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6']?: boolean;
63
- };
63
+ } | false;
64
64
  };
65
65
  keepComments?: boolean;
66
66
  components?: {
@@ -83,6 +83,7 @@ declare module '@nuxt/schema' {
83
83
  map: Record<string, string>;
84
84
  };
85
85
  headings: ModuleOptions['headings'];
86
+ useNuxtImage?: boolean;
86
87
  };
87
88
  }
88
89
  interface ConfigSchema {
package/dist/module.json CHANGED
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
3
  "configKey": "mdc",
4
- "version": "0.7.0"
4
+ "version": "0.7.1",
5
+ "builder": {
6
+ "@nuxt/module-builder": "0.6.0",
7
+ "unbuild": "2.0.0"
8
+ }
5
9
  }
package/dist/module.mjs CHANGED
@@ -204,7 +204,6 @@ const DefaultHighlightLangs = [
204
204
  "vue",
205
205
  "css",
206
206
  "html",
207
- "vue",
208
207
  "bash",
209
208
  "md",
210
209
  "mdc",
@@ -12,6 +12,7 @@
12
12
  :class="props.class"
13
13
  :body="body"
14
14
  :data="data?.data"
15
+ :unwrap="props.unwrap"
15
16
  />
16
17
  </slot>
17
18
  </template>
@@ -55,6 +56,14 @@ const props = defineProps({
55
56
  class: {
56
57
  type: [String, Array, Object],
57
58
  default: ''
59
+ },
60
+ /**
61
+ * Tags to unwrap separated by spaces
62
+ * Example: 'ul li'
63
+ */
64
+ unwrap: {
65
+ type: [Boolean, String],
66
+ default: false
58
67
  }
59
68
  })
60
69
 
@@ -4,6 +4,7 @@ import destr from "destr";
4
4
  import { kebabCase, pascalCase } from "scule";
5
5
  import { find, html } from "property-information";
6
6
  import htmlTags from "../parser/utils/html-tags-list";
7
+ import { flatUnwrap } from "../utils/node";
7
8
  const DEFAULT_SLOT = "default";
8
9
  const rxOn = /^@|^v-on:/;
9
10
  const rxBind = /^:|^v-bind:/;
@@ -27,6 +28,13 @@ export default defineComponent({
27
28
  type: Object,
28
29
  default: () => ({})
29
30
  },
31
+ /**
32
+ * Root tag to use for rendering
33
+ */
34
+ class: {
35
+ type: [String, Object],
36
+ default: void 0
37
+ },
30
38
  /**
31
39
  * Root tag to use for rendering
32
40
  */
@@ -47,6 +55,14 @@ export default defineComponent({
47
55
  components: {
48
56
  type: Object,
49
57
  default: () => ({})
58
+ },
59
+ /**
60
+ * Tags to unwrap separated by spaces
61
+ * Example: 'ul li'
62
+ */
63
+ unwrap: {
64
+ type: [Boolean, String],
65
+ default: false
50
66
  }
51
67
  },
52
68
  async setup(props) {
@@ -67,14 +83,22 @@ export default defineComponent({
67
83
  return { tags, contentKey, route };
68
84
  },
69
85
  render(ctx) {
70
- const { tags, tag, body, data, contentKey, route } = ctx;
86
+ const { tags, tag, body, data, contentKey, route, unwrap } = ctx;
71
87
  if (!body) {
72
88
  return null;
73
89
  }
74
90
  const meta = { ...data, tags, $route: route };
75
91
  const component = tag !== false ? resolveVueComponent(tag || meta.component?.name || meta.component || "div") : void 0;
76
- const childrenRenderer = renderSlots(body, h, meta, meta);
77
- return component ? h(component, { ...meta.component?.props, ...this.$attrs, key: contentKey }, childrenRenderer) : childrenRenderer.default?.();
92
+ return component ? h(component, { ...meta.component?.props, class: ctx.class, ...this.$attrs, key: contentKey }, { default: defaultSlotRenderer }) : defaultSlotRenderer?.();
93
+ function defaultSlotRenderer() {
94
+ if (unwrap) {
95
+ return flatUnwrap(
96
+ renderSlots(body, h, meta, meta).default(),
97
+ typeof unwrap === "string" ? unwrap.split(" ") : ["*"]
98
+ );
99
+ }
100
+ return renderSlots(body, h, meta, meta).default();
101
+ }
78
102
  }
79
103
  });
80
104
  function renderNode(node, h2, documentMeta, parentScope = {}) {
@@ -15,6 +15,13 @@ declare const _default: DefineComponent<{
15
15
  type: ObjectConstructor;
16
16
  default: () => {};
17
17
  };
18
+ /**
19
+ * Root tag to use for rendering
20
+ */
21
+ class: {
22
+ type: (ObjectConstructor | StringConstructor)[];
23
+ default: undefined;
24
+ };
18
25
  /**
19
26
  * Root tag to use for rendering
20
27
  */
@@ -36,10 +43,18 @@ declare const _default: DefineComponent<{
36
43
  type: PropType<Record<string, string | DefineComponent<any, any, any>>>;
37
44
  default: () => {};
38
45
  };
46
+ /**
47
+ * Tags to unwrap separated by spaces
48
+ * Example: 'ul li'
49
+ */
50
+ unwrap: {
51
+ type: (BooleanConstructor | StringConstructor)[];
52
+ default: boolean;
53
+ };
39
54
  }, {
40
55
  tags: any;
41
56
  contentKey: import("vue").ComputedRef<string>;
42
- route: any;
57
+ route: {} | undefined;
43
58
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
44
59
  /**
45
60
  * Content to render
@@ -55,6 +70,13 @@ declare const _default: DefineComponent<{
55
70
  type: ObjectConstructor;
56
71
  default: () => {};
57
72
  };
73
+ /**
74
+ * Root tag to use for rendering
75
+ */
76
+ class: {
77
+ type: (ObjectConstructor | StringConstructor)[];
78
+ default: undefined;
79
+ };
58
80
  /**
59
81
  * Root tag to use for rendering
60
82
  */
@@ -76,10 +98,20 @@ declare const _default: DefineComponent<{
76
98
  type: PropType<Record<string, string | DefineComponent<any, any, any>>>;
77
99
  default: () => {};
78
100
  };
101
+ /**
102
+ * Tags to unwrap separated by spaces
103
+ * Example: 'ul li'
104
+ */
105
+ unwrap: {
106
+ type: (BooleanConstructor | StringConstructor)[];
107
+ default: boolean;
108
+ };
79
109
  }>>, {
80
110
  data: Record<string, any>;
111
+ class: string | Record<string, any>;
81
112
  tag: string | boolean;
82
- components: Record<string, string | DefineComponent<any, any, any>>;
83
113
  prose: boolean;
114
+ components: Record<string, string | DefineComponent<any, any, any>>;
115
+ unwrap: string | boolean;
84
116
  }, {}>;
85
117
  export default _default;
@@ -1,5 +1,56 @@
1
+ import type { Slot } from 'vue';
1
2
  /**
2
3
  * MDCSlot component
3
4
  */
4
- declare const _default: any;
5
+ declare const _default: import("vue").DefineComponent<{
6
+ name: {
7
+ type: StringConstructor;
8
+ default: string;
9
+ };
10
+ /**
11
+ * Tags to unwrap separated by spaces
12
+ * Example: 'ul li'
13
+ */
14
+ unwrap: {
15
+ type: (BooleanConstructor | StringConstructor)[];
16
+ default: boolean;
17
+ };
18
+ /**
19
+ * VNode to render
20
+ * This is only useful for render functions
21
+ */
22
+ use: {
23
+ type: FunctionConstructor;
24
+ default: undefined;
25
+ };
26
+ }, {
27
+ fallbackSlot: Slot<any> | undefined;
28
+ tags: import("vue").ComputedRef<string[]>;
29
+ parent: import("vue").ComponentInternalInstance | null;
30
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
31
+ name: {
32
+ type: StringConstructor;
33
+ default: string;
34
+ };
35
+ /**
36
+ * Tags to unwrap separated by spaces
37
+ * Example: 'ul li'
38
+ */
39
+ unwrap: {
40
+ type: (BooleanConstructor | StringConstructor)[];
41
+ default: boolean;
42
+ };
43
+ /**
44
+ * VNode to render
45
+ * This is only useful for render functions
46
+ */
47
+ use: {
48
+ type: FunctionConstructor;
49
+ default: undefined;
50
+ };
51
+ }>>, {
52
+ name: string;
53
+ unwrap: string | boolean;
54
+ use: Function;
55
+ }, {}>;
5
56
  export default _default;
@@ -79,6 +79,7 @@ export function compileHast(options = {}) {
79
79
  }
80
80
  }
81
81
  }
82
+ body.children = (body.children || []).filter((child) => child.type !== "text");
82
83
  return {
83
84
  body,
84
85
  excerpt
@@ -1,3 +1,2 @@
1
- import type { Processor } from 'remark-rehype/lib';
2
1
  import type { MDCParseOptions } from '../../types';
3
2
  export declare const useProcessorPlugins: (processor: Processor, plugins?: Exclude<MDCParseOptions['rehype'] | MDCParseOptions['remark'], undefined>['plugins']) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Nuxt MDC module",
5
5
  "repository": "nuxt-modules/mdc",
6
6
  "license": "MIT",
@@ -71,10 +71,10 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "@nuxt/kit": "^3.11.2",
74
- "@shikijs/transformers": "^1.3.0",
74
+ "@shikijs/transformers": "^1.5.2",
75
75
  "@types/hast": "^3.0.4",
76
- "@types/mdast": "^4.0.3",
77
- "@vue/compiler-core": "^3.4.24",
76
+ "@types/mdast": "^4.0.4",
77
+ "@vue/compiler-core": "^3.4.27",
78
78
  "consola": "^3.2.3",
79
79
  "debug": "^4.3.4",
80
80
  "defu": "^6.1.4",
@@ -95,11 +95,11 @@
95
95
  "rehype-sort-attributes": "^5.0.0",
96
96
  "remark-emoji": "^4.0.1",
97
97
  "remark-gfm": "^4.0.0",
98
- "remark-mdc": "^3.2.0",
98
+ "remark-mdc": "^3.2.1",
99
99
  "remark-parse": "^11.0.0",
100
100
  "remark-rehype": "^11.1.0",
101
101
  "scule": "^1.3.0",
102
- "shiki": "^1.3.0",
102
+ "shiki": "^1.5.2",
103
103
  "ufo": "^1.5.3",
104
104
  "unified": "^11.0.4",
105
105
  "unist-builder": "^4.0.0",
@@ -108,19 +108,18 @@
108
108
  },
109
109
  "devDependencies": {
110
110
  "@nuxt/devtools": "latest",
111
- "@nuxt/eslint-config": "^0.3.9",
112
- "@nuxt/module-builder": "^0.5.5",
111
+ "@nuxt/eslint-config": "^0.3.12",
112
+ "@nuxt/module-builder": "^0.6.0",
113
113
  "@nuxt/schema": "^3.11.2",
114
- "@nuxt/test-utils": "^3.12.1",
115
- "@nuxt/ui": "^2.15.2",
116
- "@types/mdurl": "^1.0.5",
117
- "@types/node": "^20.12.7",
114
+ "@nuxt/test-utils": "^3.13.0",
115
+ "@nuxt/ui": "^2.16.0",
116
+ "@types/node": "^20.12.12",
118
117
  "changelogen": "^0.5.5",
119
- "eslint": "^9.1.1",
118
+ "eslint": "^9.2.0",
120
119
  "nuxt": "^3.11.2",
121
120
  "rehype": "^13.0.1",
122
- "release-it": "^17.2.0",
123
- "vitest": "^1.5.0"
121
+ "release-it": "^17.2.1",
122
+ "vitest": "^1.6.0"
124
123
  },
125
124
  "release-it": {
126
125
  "git": {
@@ -1,9 +0,0 @@
1
- import { BuiltinTheme } from 'shiki';
2
-
3
- type MdcThemeOptions = BuiltinTheme | string | Record<string, BuiltinTheme | string>;
4
- interface HighlighterOptions {
5
- highlights?: number[];
6
- meta?: string;
7
- }
8
-
9
- export type { HighlighterOptions as H, MdcThemeOptions as M };
@@ -1,9 +0,0 @@
1
- import { BuiltinTheme } from 'shiki';
2
-
3
- type MdcThemeOptions = BuiltinTheme | string | Record<string, BuiltinTheme | string>;
4
- interface HighlighterOptions {
5
- highlights?: number[];
6
- meta?: string;
7
- }
8
-
9
- export type { HighlighterOptions as H, MdcThemeOptions as M };