@nuxtjs/mdc 0.1.3 → 0.1.4

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/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
3
  "configKey": "mdc",
4
- "version": "0.1.3"
4
+ "version": "0.1.4"
5
5
  }
package/dist/module.mjs CHANGED
@@ -51,27 +51,6 @@ function processUnistPlugins(plugins) {
51
51
  const registerMDCSlotTransformer = (resolver) => {
52
52
  extendViteConfig((config) => {
53
53
  const compilerOptions = config.vue.template.compilerOptions;
54
- config.plugins = config.plugins || [];
55
- config.plugins.push({
56
- name: "mdc-render-slot-import",
57
- enforce: "post",
58
- transform(code) {
59
- if (code.includes("_renderMDCSlot")) {
60
- return {
61
- code: `import { renderSlot as _renderMDCSlot } from '${resolver.resolve("./runtime/utils/slot")}';
62
- ${code}`,
63
- map: { mappings: "" }
64
- };
65
- }
66
- if (code.includes("_ssrRenderMDCSlot")) {
67
- return {
68
- code: `import { ssrRenderSlot as _ssrRenderMDCSlot } from '${resolver.resolve("./runtime/utils/ssrSlot")}';
69
- ${code}`,
70
- map: { mappings: "" }
71
- };
72
- }
73
- }
74
- });
75
54
  compilerOptions.nodeTransforms = [
76
55
  function viteMDCSlot(node, context) {
77
56
  if (node.tag === "MDCSlot") {
@@ -83,6 +62,10 @@ ${code}`,
83
62
  transform?.(node, context);
84
63
  const codegen = context.ssr ? node.ssrCodegenNode : node.codegenNode;
85
64
  codegen.callee = codegen.callee === RENDER_SLOT ? "_renderMDCSlot" : "_ssrRenderMDCSlot";
65
+ context.imports.push({
66
+ exp: context.ssr ? "{ ssrRenderSlot as _ssrRenderMDCSlot }" : "{ renderSlot as _renderMDCSlot }",
67
+ path: resolver.resolve(`./runtime/utils/${context.ssr ? "ssrSlot" : "slot"}`)
68
+ });
86
69
  };
87
70
  }
88
71
  if (context.nodeTransforms[0].name !== "viteMDCSlot") {
@@ -28,7 +28,7 @@ const props = defineProps({
28
28
  }
29
29
  })
30
30
 
31
- const { data, refresh } = await useAsyncData(async () => await parseMarkdown(props.value, { highlight: {}}))
31
+ const { data, refresh } = await useAsyncData(props.value, async () => await parseMarkdown(props.value, { highlight: {}}))
32
32
 
33
33
  watch(() => props.value, () => {
34
34
  refresh()
@@ -1,4 +1,4 @@
1
- import type { VNode } from 'vue';
1
+ import { type VNode } from 'vue';
2
2
  import type { MDCElement, MDCNode } from '../types';
3
3
  /**
4
4
  * List of text nodes
@@ -1,3 +1,4 @@
1
+ import { Text } from "vue";
1
2
  export const TEXT_TAGS = ["p", "h1", "h2", "h3", "h4", "h5", "h6", "li"];
2
3
  export function isTag(vnode, tag) {
3
4
  if (vnode.type === tag) {
@@ -12,7 +13,7 @@ export function isTag(vnode, tag) {
12
13
  return false;
13
14
  }
14
15
  export function isText(vnode) {
15
- return isTag(vnode, "text") || typeof vnode.children === "string";
16
+ return isTag(vnode, "text") || isTag(vnode, Text);
16
17
  }
17
18
  export function nodeChildren(node) {
18
19
  if (Array.isArray(node.children) || typeof node.children === "string") {
@@ -31,11 +32,11 @@ export function nodeTextContent(node) {
31
32
  return node.map(nodeTextContent).join("");
32
33
  }
33
34
  if (isText(node)) {
34
- return node.children || node.value;
35
+ return node.children || node.value || "";
35
36
  }
36
37
  const children = nodeChildren(node);
37
38
  if (Array.isArray(children)) {
38
- return children.map(nodeTextContent).join("");
39
+ return children.map(nodeTextContent).filter(Boolean).join("");
39
40
  }
40
41
  return "";
41
42
  }
@@ -61,7 +62,7 @@ function _flatUnwrap(vnodes, tags = ["p"]) {
61
62
  }
62
63
  export function flatUnwrap(vnodes, tags = ["p"]) {
63
64
  return _flatUnwrap(vnodes, tags).reduce((acc, item) => {
64
- if (typeof item.children === "string") {
65
+ if (isText(item)) {
65
66
  if (typeof acc[acc.length - 1] === "string") {
66
67
  acc[acc.length - 1] += item.children;
67
68
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Nuxt MDC module",
5
5
  "repository": "nuxt-modules/mdc",
6
6
  "license": "MIT",