@slicemachine/adapter-nuxt2 0.3.50-beta.1 → 0.3.50-beta.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,7 @@ const format = async (input, helpers) => {
14
14
  return formattedInput.endsWith(";") ? formattedInput.substring(0, formattedInput.length - 1) : formattedInput;
15
15
  };
16
16
  const snippetRead = async (data, { helpers }) => {
17
+ var _a;
17
18
  const { fieldPath, itemName } = data;
18
19
  const label = "Vue";
19
20
  switch (data.model.type) {
@@ -39,9 +40,11 @@ const snippetRead = async (data, { helpers }) => {
39
40
  return {
40
41
  label,
41
42
  language: "vue",
42
- code: await format(commonTags.stripIndent`
43
- <PrismicLink :field="${dotPath(fieldPath)}">Link</PrismicLink>
44
- `, helpers)
43
+ code: await format(((_a = data.model.config) == null ? void 0 : _a.allowText) ? commonTags.stripIndent`
44
+ <PrismicLink :field="${dotPath(fieldPath)}" />
45
+ ` : commonTags.stripIndent`
46
+ <PrismicLink :field="${dotPath(fieldPath)}">Link</PrismicLink>
47
+ `, helpers)
45
48
  };
46
49
  }
47
50
  case "Image": {
@@ -1 +1 @@
1
- {"version":3,"file":"snippet-read.cjs","sources":["../../../src/hooks/snippet-read.ts"],"sourcesContent":["import type {\n\tSliceMachineHelpers,\n\tSnippetReadHook,\n} from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst dotPath = (segments: string[]): string => {\n\treturn segments.join(\".\");\n};\n\nconst format = async (input: string, helpers: SliceMachineHelpers) => {\n\tconst formattedInput = await helpers.format(input, undefined, {\n\t\tincludeNewlineAtEnd: false,\n\t\tprettier: {\n\t\t\tparser: \"vue\",\n\t\t},\n\t});\n\n\treturn formattedInput.endsWith(\";\")\n\t\t? formattedInput.substring(0, formattedInput.length - 1)\n\t\t: formattedInput;\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath, itemName } = data;\n\n\tconst label = \"Vue\";\n\n\tswitch (data.model.type) {\n\t\tcase \"StructuredText\": {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (rich)`,\n\t\t\t\t\tlanguage: \"vue\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicRichText :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t`,\n\t\t\t\t\t\thelpers,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (plain)`,\n\t\t\t\t\tlanguage: \"vue\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicText :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t`,\n\t\t\t\t\t\thelpers,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicLink :field=\"${dotPath(fieldPath)}\">Link</PrismicLink>\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicImage :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicEmbed :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<template v-for=\"${itemName} in ${dotPath(fieldPath)}\">\n\t\t\t\t\t\t\t{{ ${itemName} }}\n\t\t\t\t\t\t</template>\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\t:slices=\"${dotPath(fieldPath)}\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t`,\n\t\t\t\thelpers,\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t{{${dotPath(fieldPath)}}}\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n};\n"],"names":["stripIndent"],"mappings":";;;AAQA,MAAM,UAAU,CAAC,aAA8B;AACvC,SAAA,SAAS,KAAK,GAAG;AACzB;AAEA,MAAM,SAAS,OAAO,OAAe,YAAgC;AACpE,QAAM,iBAAiB,MAAM,QAAQ,OAAO,OAAO,QAAW;AAAA,IAC7D,qBAAqB;AAAA,IACrB,UAAU;AAAA,MACT,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEM,SAAA,eAAe,SAAS,GAAG,IAC/B,eAAe,UAAU,GAAG,eAAe,SAAS,CAAC,IACrD;AACJ;AAEO,MAAM,cAA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A,QACV;AAAA,MAAA;AAAA,IAEF;AAAA,IAEA,SAAS;AACD,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV,MAAM,MAAM,OACXA;UACK,QAAQ,SAAS;AAAA,QAEtB,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"snippet-read.cjs","sources":["../../../src/hooks/snippet-read.ts"],"sourcesContent":["import type {\n\tSliceMachineHelpers,\n\tSnippetReadHook,\n} from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst dotPath = (segments: string[]): string => {\n\treturn segments.join(\".\");\n};\n\nconst format = async (input: string, helpers: SliceMachineHelpers) => {\n\tconst formattedInput = await helpers.format(input, undefined, {\n\t\tincludeNewlineAtEnd: false,\n\t\tprettier: {\n\t\t\tparser: \"vue\",\n\t\t},\n\t});\n\n\treturn formattedInput.endsWith(\";\")\n\t\t? formattedInput.substring(0, formattedInput.length - 1)\n\t\t: formattedInput;\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath, itemName } = data;\n\n\tconst label = \"Vue\";\n\n\tswitch (data.model.type) {\n\t\tcase \"StructuredText\": {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (rich)`,\n\t\t\t\t\tlanguage: \"vue\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicRichText :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t`,\n\t\t\t\t\t\thelpers,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (plain)`,\n\t\t\t\t\tlanguage: \"vue\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicText :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t`,\n\t\t\t\t\t\thelpers,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tdata.model.config?.allowText\n\t\t\t\t\t\t? stripIndent`\n\t\t\t\t\t\t\t<PrismicLink :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`\n\t\t\t\t\t\t: stripIndent`\n\t\t\t\t\t\t\t<PrismicLink :field=\"${dotPath(fieldPath)}\">Link</PrismicLink>\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicImage :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicEmbed :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<template v-for=\"${itemName} in ${dotPath(fieldPath)}\">\n\t\t\t\t\t\t\t{{ ${itemName} }}\n\t\t\t\t\t\t</template>\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\t:slices=\"${dotPath(fieldPath)}\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t`,\n\t\t\t\thelpers,\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t{{${dotPath(fieldPath)}}}\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n};\n"],"names":["stripIndent"],"mappings":";;;AAQA,MAAM,UAAU,CAAC,aAA8B;AACvC,SAAA,SAAS,KAAK,GAAG;AACzB;AAEA,MAAM,SAAS,OAAO,OAAe,YAAgC;AACpE,QAAM,iBAAiB,MAAM,QAAQ,OAAO,OAAO,QAAW;AAAA,IAC7D,qBAAqB;AAAA,IACrB,UAAU;AAAA,MACT,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEM,SAAA,eAAe,SAAS,GAAG,IAC/B,eAAe,UAAU,GAAG,eAAe,SAAS,CAAC,IACrD;AACJ;AAEO,MAAM,cAA8C,OAC1D,MACA,EAAE,cACC;;AACG,QAAA,EAAE,WAAW,SAAa,IAAA;AAEhC,QAAM,QAAQ;AAEN,UAAA,KAAK,MAAM,MAAM;AAAA,IACxB,KAAK,kBAAkB;AACf,aAAA;AAAA,QACN;AAAA,UACC,OAAO,GAAG;AAAA,UACV,UAAU;AAAA,UACV,MAAM,MAAM,OACXA;iCAC2B,QAAQ,SAAS;AAAA,QAE5C,OAAO;AAAA,QAER;AAAA,QACD;AAAA,UACC,OAAO,GAAG;AAAA,UACV,UAAU;AAA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ith(";") ? formattedInput.substring(0, formattedInput.length - 1) : formattedInput;
13
13
  };
14
14
  const snippetRead = async (data, { helpers }) => {
15
+ var _a;
15
16
  const { fieldPath, itemName } = data;
16
17
  const label = "Vue";
17
18
  switch (data.model.type) {
@@ -37,9 +38,11 @@ const snippetRead = async (data, { helpers }) => {
37
38
  return {
38
39
  label,
39
40
  language: "vue",
40
- code: await format(stripIndent`
41
- <PrismicLink :field="${dotPath(fieldPath)}">Link</PrismicLink>
42
- `, helpers)
41
+ code: await format(((_a = data.model.config) == null ? void 0 : _a.allowText) ? stripIndent`
42
+ <PrismicLink :field="${dotPath(fieldPath)}" />
43
+ ` : stripIndent`
44
+ <PrismicLink :field="${dotPath(fieldPath)}">Link</PrismicLink>
45
+ `, helpers)
43
46
  };
44
47
  }
45
48
  case "Image": {
@@ -1 +1 @@
1
- {"version":3,"file":"snippet-read.js","sources":["../../../src/hooks/snippet-read.ts"],"sourcesContent":["import type {\n\tSliceMachineHelpers,\n\tSnippetReadHook,\n} from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst dotPath = (segments: string[]): string => {\n\treturn segments.join(\".\");\n};\n\nconst format = async (input: string, helpers: SliceMachineHelpers) => {\n\tconst formattedInput = await helpers.format(input, undefined, {\n\t\tincludeNewlineAtEnd: false,\n\t\tprettier: {\n\t\t\tparser: \"vue\",\n\t\t},\n\t});\n\n\treturn formattedInput.endsWith(\";\")\n\t\t? formattedInput.substring(0, formattedInput.length - 1)\n\t\t: formattedInput;\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath, itemName } = data;\n\n\tconst label = \"Vue\";\n\n\tswitch (data.model.type) {\n\t\tcase \"StructuredText\": {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (rich)`,\n\t\t\t\t\tlanguage: \"vue\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicRichText :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t`,\n\t\t\t\t\t\thelpers,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (plain)`,\n\t\t\t\t\tlanguage: \"vue\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicText :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t`,\n\t\t\t\t\t\thelpers,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicLink :field=\"${dotPath(fieldPath)}\">Link</PrismicLink>\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicImage :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicEmbed :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<template v-for=\"${itemName} in ${dotPath(fieldPath)}\">\n\t\t\t\t\t\t\t{{ ${itemName} }}\n\t\t\t\t\t\t</template>\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\t:slices=\"${dotPath(fieldPath)}\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t`,\n\t\t\t\thelpers,\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t{{${dotPath(fieldPath)}}}\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n};\n"],"names":[],"mappings":";AAQA,MAAM,UAAU,CAAC,aAA8B;AACvC,SAAA,SAAS,KAAK,GAAG;AACzB;AAEA,MAAM,SAAS,OAAO,OAAe,YAAgC;AACpE,QAAM,iBAAiB,MAAM,QAAQ,OAAO,OAAO,QAAW;AAAA,IAC7D,qBAAqB;AAAA,IACrB,UAAU;AAAA,MACT,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEM,SAAA,eAAe,SAAS,GAAG,IAC/B,eAAe,UAAU,GAAG,eAAe,SAAS,CAAC,IACrD;AACJ;AAEO,MAAM,cAA8C,OAC1D,MACA,EAAE,cACC;AACG,QAAA,EAAE,WAAW,SAAa,IAAA;AAEhC,QAAM,QAAQ;AAEN,UAAA,KAAK,MAAM,MAAM;AAAA,IACxB,KAAK,kBAAkB;AACf,aAAA;AAAA,QACN;A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ACK,QAAQ,SAAS;AAAA,QAEtB,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"snippet-read.js","sources":["../../../src/hooks/snippet-read.ts"],"sourcesContent":["import type {\n\tSliceMachineHelpers,\n\tSnippetReadHook,\n} from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst dotPath = (segments: string[]): string => {\n\treturn segments.join(\".\");\n};\n\nconst format = async (input: string, helpers: SliceMachineHelpers) => {\n\tconst formattedInput = await helpers.format(input, undefined, {\n\t\tincludeNewlineAtEnd: false,\n\t\tprettier: {\n\t\t\tparser: \"vue\",\n\t\t},\n\t});\n\n\treturn formattedInput.endsWith(\";\")\n\t\t? formattedInput.substring(0, formattedInput.length - 1)\n\t\t: formattedInput;\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath, itemName } = data;\n\n\tconst label = \"Vue\";\n\n\tswitch (data.model.type) {\n\t\tcase \"StructuredText\": {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (rich)`,\n\t\t\t\t\tlanguage: \"vue\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicRichText :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t`,\n\t\t\t\t\t\thelpers,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (plain)`,\n\t\t\t\t\tlanguage: \"vue\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicText :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t`,\n\t\t\t\t\t\thelpers,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tdata.model.config?.allowText\n\t\t\t\t\t\t? stripIndent`\n\t\t\t\t\t\t\t<PrismicLink :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`\n\t\t\t\t\t\t: stripIndent`\n\t\t\t\t\t\t\t<PrismicLink :field=\"${dotPath(fieldPath)}\">Link</PrismicLink>\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicImage :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicEmbed :field=\"${dotPath(fieldPath)}\" />\n\t\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<template v-for=\"${itemName} in ${dotPath(fieldPath)}\">\n\t\t\t\t\t\t\t{{ ${itemName} }}\n\t\t\t\t\t\t</template>\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\t:slices=\"${dotPath(fieldPath)}\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t`,\n\t\t\t\thelpers,\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"vue\",\n\t\t\t\tcode: await format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t{{${dotPath(fieldPath)}}}\n\t\t\t\t\t`,\n\t\t\t\t\thelpers,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n};\n"],"names":[],"mappings":";AAQA,MAAM,UAAU,CAAC,aAA8B;AACvC,SAAA,SAAS,KAAK,GAAG;AACzB;AAEA,MAAM,SAAS,OAAO,OAAe,YAAgC;AACpE,QAAM,iBAAiB,MAAM,QAAQ,OAAO,OAAO,QAAW;AAAA,IAC7D,qBAAqB;AAAA,IACrB,UAAU;AAAA,MACT,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEM,SAAA,eAAe,SAAS,GAAG,IAC/B,eAAe,UAAU,GAAG,eAAe,SAAS,CAAC,IACrD;AACJ;AAEO,MAAM,cAA8C,OAC1D,MACA,EAAE,cACC;;AACG,QAAA,EAAE,WAAW,SAAa,IAAA;AAEhC,QAAM,QAAQ;AAEN,UAAA,KAAK,MAAM,MAAM;AAAA,IACxB,KAAK,kBAAkB;AACf,aAAA;AAAA,QACN;AAAA,UACC,OAAO,GAAG;AAAA,UACV,UAAU;AAAA,UACV,MAAM,MAAM,OACX;AAAA,iCAC2B,QAAQ,SAAS;AAAA,QAE5C,OAAO;AAAA,QAER;AAAA,QACD;AAAA,UACC,OAAO,GAAG;AAAA,UACV,UAAU;AAAA,UACV,MAAM,MAAM,OACX;AAAA,6BACuB,QAAQ,SAAS;AAAA,QAExC,OAAO;AAAA,QAER;AAAA,MAAA;AAAA,IAEH;AAAA,IAEA,KAAK,QAAQ;AACL,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV,MAAM,MAAM,SACX,UAAK,MAAM,WAAX,mBAAmB,aAChB;AAAA,8BACsB,QAAQ,SAAS;AAAA,UAEvC;AAAA,8BACsB,QAAQ,SAAS;AAAA,SAE1C,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,IAEA,KAAK,SAAS;AACN,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV,MAAM,MAAM,OACX;AAAA,+BAC0B,QAAQ,SAAS;AAAA,SAE3C,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,IAEA,KAAK,SAAS;AACN,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV,MAAM,MAAM,OACX;AAAA,+BAC0B,QAAQ,SAAS;AAAA,SAE3C,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,IAEA,KAAK,SAAS;AACN,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV,MAAM,MAAM,OACX;AAAA,yBACoB,eAAe,QAAQ,SAAS;AAAA,YAC7C;AAAA;AAAA,QAGP,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,IAEA,KAAK,UAAU;AACR,YAAA,OAAO,MAAM,OAClB;AAAA;AAAA,iBAEa,QAAQ,SAAS;AAAA;AAAA;AAAA,OAI9B,OAAO;AAGD,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV;AAAA,MAAA;AAAA,IAEF;AAAA,IAEA,SAAS;AACD,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV,MAAM,MAAM,OACX;AAAA,UACK,QAAQ,SAAS;AAAA,QAEtB,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,EACD;AACD;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-nuxt2",
3
- "version": "0.3.50-beta.1",
3
+ "version": "0.3.50-beta.3",
4
4
  "description": "Slice Machine adapter for Nuxt 2.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -60,8 +60,8 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@prismicio/simulator": "^0.1.4",
63
- "@prismicio/types-internal": "^2.5.0",
64
- "@slicemachine/plugin-kit": "0.4.50-beta.1",
63
+ "@prismicio/types-internal": "^2.8.0",
64
+ "@slicemachine/plugin-kit": "0.4.50-beta.3",
65
65
  "common-tags": "^1.8.2",
66
66
  "fp-ts": "^2.13.1",
67
67
  "io-ts": "^2.2.20",
@@ -85,7 +85,7 @@
85
85
  "nuxt": "2.16.3",
86
86
  "prettier": "3.0.3",
87
87
  "prettier-plugin-jsdoc": "1.1.1",
88
- "prismic-ts-codegen": "^0.1.21",
88
+ "prismic-ts-codegen": "^0.1.22",
89
89
  "size-limit": "8.2.4",
90
90
  "ts-morph": "17.0.1",
91
91
  "typescript": "4.9.5",
@@ -62,9 +62,13 @@ export const snippetRead: SnippetReadHook<PluginOptions> = async (
62
62
  label,
63
63
  language: "vue",
64
64
  code: await format(
65
- stripIndent`
66
- <PrismicLink :field="${dotPath(fieldPath)}">Link</PrismicLink>
67
- `,
65
+ data.model.config?.allowText
66
+ ? stripIndent`
67
+ <PrismicLink :field="${dotPath(fieldPath)}" />
68
+ `
69
+ : stripIndent`
70
+ <PrismicLink :field="${dotPath(fieldPath)}">Link</PrismicLink>
71
+ `,
68
72
  helpers,
69
73
  ),
70
74
  };