@slicemachine/adapter-sveltekit 0.3.50-alpha.dani-link-text-templates.1 → 0.3.50-alpha.dani-link-snippets.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,7 @@ const format = async (input, helpers) => {
15
15
  return formattedInput;
16
16
  };
17
17
  const snippetRead = async (data, { helpers }) => {
18
+ var _a;
18
19
  const { fieldPath, itemName } = data;
19
20
  const label = "Svelte";
20
21
  switch (data.model.type) {
@@ -40,9 +41,11 @@ const snippetRead = async (data, { helpers }) => {
40
41
  return {
41
42
  label,
42
43
  language: "svelte",
43
- code: await format(commonTags.stripIndent`
44
- <PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>
45
- `, helpers)
44
+ code: await format(((_a = data.model.config) == null ? void 0 : _a.allowText) ? commonTags.stripIndent`
45
+ <PrismicLink field={${dotPath(fieldPath)}} />
46
+ ` : commonTags.stripIndent`
47
+ <PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>
48
+ `, helpers)
46
49
  };
47
50
  }
48
51
  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[])[]): string => {\n\treturn segments.flat().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\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\tparser: \"svelte\",\n\t\t},\n\t});\n\n\treturn formattedInput;\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath, itemName } = data;\n\n\tconst label = \"Svelte\";\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} (components)`,\n\t\t\t\t\tlanguage: \"svelte\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicRichText field={${dotPath(fieldPath)}} />\n\t\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 text)`,\n\t\t\t\t\tlanguage: \"svelte\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicText field={${dotPath(fieldPath)}} />\n\t\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: \"svelte\",\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: \"svelte\",\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 \"Group\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{#each ${dotPath(fieldPath)} as ${itemName}}\n\t\t\t\t\t\t<!-- Render content for ${itemName} -->\n\t\t\t\t\t{/each}\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: \"svelte\",\n\t\t\t\tcode,\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 slices={${dotPath(fieldPath)}}\n\t\t\t\t\t {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: \"svelte\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{${dotPath(fieldPath, \"latitude\")}}, {${dotPath(fieldPath, \"longitude\")}}\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: \"svelte\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{@html ${dotPath(fieldPath, \"html\")}}\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: \"svelte\",\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: \"svelte\",\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,IAAI,aAA2C;AAC9D,SAAO,SAAS,KAAA,EAAO,KAAK,GAAG;AAChC;AAEA,MAAM,SAAS,OAAO,OAAe,YAAgC;AACpE,QAAM,iB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GD,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV;AAAA,MAAA;AAAA,IAEF;AAAA,IAEA,KAAK,YAAY;AACV,YAAA,OAAO,MAAM,OAClBA;QACI,QAAQ,WAAW,UAAU,QAAQ,QAAQ,WAAW,WAAW;AAAA,OAEvE,OAAO;AAGD,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV;AAAA,MAAA;AAAA,IAEF;AAAA,IAEA,KAAK,SAAS;AACP,YAAA,OAAO,MAAM,OAClBA;cACU,QAAQ,WAAW,MAAM;AAAA,OAEnC,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,OACXA;SACI,QAAQ,SAAS;AAAA,QAErB,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[])[]): string => {\n\treturn segments.flat().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\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\tparser: \"svelte\",\n\t\t},\n\t});\n\n\treturn formattedInput;\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath, itemName } = data;\n\n\tconst label = \"Svelte\";\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} (components)`,\n\t\t\t\t\tlanguage: \"svelte\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicRichText field={${dotPath(fieldPath)}} />\n\t\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 text)`,\n\t\t\t\t\tlanguage: \"svelte\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicText field={${dotPath(fieldPath)}} />\n\t\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: \"svelte\",\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: \"svelte\",\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 \"Group\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{#each ${dotPath(fieldPath)} as ${itemName}}\n\t\t\t\t\t\t<!-- Render content for ${itemName} -->\n\t\t\t\t\t{/each}\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: \"svelte\",\n\t\t\t\tcode,\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 slices={${dotPath(fieldPath)}}\n\t\t\t\t\t {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: \"svelte\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{${dotPath(fieldPath, \"latitude\")}}, {${dotPath(fieldPath, \"longitude\")}}\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: \"svelte\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{@html ${dotPath(fieldPath, \"html\")}}\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: \"svelte\",\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: \"svelte\",\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,IAAI,aAA2C;AAC9D,SAAO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;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV;AAAA,MAAA;AAAA,IAEF;AAAA,IAEA,KAAK,UAAU;AACR,YAAA,OAAO,MAAM,OAClBA;;iBAEa,QAAQ,SAAS;AAAA;AAAA;AAAA,OAI9B,OAAO;AAGD,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV;AAAA,MAAA;AAAA,IAEF;AAAA,IAEA,KAAK,YAAY;AACV,YAAA,OAAO,MAAM,OAClBA;QACI,QAAQ,WAAW,UAAU,QAAQ,QAAQ,WAAW,WAAW;AAAA,OAEvE,OAAO;AAGD,aAAA;AAAA,QACN;AAAA,QACA,UAAU;AAAA,QACV;AAAA,MAAA;AAAA,IAEF;AAAA,IAEA,KAAK,SAAS;AACP,YAAA,OAAO,MAAM,OAClBA;cACU,QAAQ,WAAW,MAAM;AAAA,OAEnC,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,OACXA;SACI,QAAQ,SAAS;AAAA,QAErB,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,EACD;AACD;;"}
@@ -13,6 +13,7 @@ const format = async (input, helpers) => {
13
13
  return formattedInput;
14
14
  };
15
15
  const snippetRead = async (data, { helpers }) => {
16
+ var _a;
16
17
  const { fieldPath, itemName } = data;
17
18
  const label = "Svelte";
18
19
  switch (data.model.type) {
@@ -38,9 +39,11 @@ const snippetRead = async (data, { helpers }) => {
38
39
  return {
39
40
  label,
40
41
  language: "svelte",
41
- code: await format(stripIndent`
42
- <PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>
43
- `, helpers)
42
+ code: await format(((_a = data.model.config) == null ? void 0 : _a.allowText) ? stripIndent`
43
+ <PrismicLink field={${dotPath(fieldPath)}} />
44
+ ` : stripIndent`
45
+ <PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>
46
+ `, helpers)
44
47
  };
45
48
  }
46
49
  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[])[]): string => {\n\treturn segments.flat().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\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\tparser: \"svelte\",\n\t\t},\n\t});\n\n\treturn formattedInput;\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath, itemName } = data;\n\n\tconst label = \"Svelte\";\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} (components)`,\n\t\t\t\t\tlanguage: \"svelte\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicRichText field={${dotPath(fieldPath)}} />\n\t\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 text)`,\n\t\t\t\t\tlanguage: \"svelte\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicText field={${dotPath(fieldPath)}} />\n\t\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: \"svelte\",\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: \"svelte\",\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 \"Group\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{#each ${dotPath(fieldPath)} as ${itemName}}\n\t\t\t\t\t\t<!-- Render content for ${itemName} -->\n\t\t\t\t\t{/each}\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: \"svelte\",\n\t\t\t\tcode,\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 slices={${dotPath(fieldPath)}}\n\t\t\t\t\t {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: \"svelte\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{${dotPath(fieldPath, \"latitude\")}}, {${dotPath(fieldPath, \"longitude\")}}\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: \"svelte\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{@html ${dotPath(fieldPath, \"html\")}}\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: \"svelte\",\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: \"svelte\",\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,IAAI,aAA2C;AAC9D,SAAO,SAAS,KAAA,EAAO,KAAK,GAAG;AAChC;AAEA,MAAM,SAAS,OAAO,OAAe,YAAgC;AACpE,QAAM,iBAAiB,MAAM,QAAQ,OAAO,OAAO,QAAW;AAAA,IAC7D,qBAAqB;AAAA,IACrB,UAAU;AAAA,MACT,SAAS,CAAC,wBAAwB;AAAA,MAClC,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEM,SAAA;AACR;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,SAE5C,OAAO;AAAA,QAER;AAAA,QACD;AAAA,UACC,OAAO,GAAG;AAAA,UACV,UAAU;AAAA,UACV,MAAM,MAAM,OACX;AAAA,6BACuB,QAAQ,SAAS;AAAA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AAQ,SAAS;AAAA,QAErB,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[])[]): string => {\n\treturn segments.flat().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\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\tparser: \"svelte\",\n\t\t},\n\t});\n\n\treturn formattedInput;\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath, itemName } = data;\n\n\tconst label = \"Svelte\";\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} (components)`,\n\t\t\t\t\tlanguage: \"svelte\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicRichText field={${dotPath(fieldPath)}} />\n\t\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 text)`,\n\t\t\t\t\tlanguage: \"svelte\",\n\t\t\t\t\tcode: await format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicText field={${dotPath(fieldPath)}} />\n\t\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: \"svelte\",\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: \"svelte\",\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 \"Group\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{#each ${dotPath(fieldPath)} as ${itemName}}\n\t\t\t\t\t\t<!-- Render content for ${itemName} -->\n\t\t\t\t\t{/each}\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: \"svelte\",\n\t\t\t\tcode,\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 slices={${dotPath(fieldPath)}}\n\t\t\t\t\t {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: \"svelte\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{${dotPath(fieldPath, \"latitude\")}}, {${dotPath(fieldPath, \"longitude\")}}\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: \"svelte\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst code = await format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t{@html ${dotPath(fieldPath, \"html\")}}\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: \"svelte\",\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: \"svelte\",\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,IAAI,aAA2C;AAC9D,SAAO,SAAS,KAAA,EAAO,KAAK,GAAG;AAChC;AAEA,MAAM,SAAS,OAAO,OAAe,YAAgC;AACpE,QAAM,iBAAiB,MAAM,QAAQ,OAAO,OAAO,QAAW;AAAA,IAC7D,qBAAqB;AAAA,IACrB,UAAU;AAAA,MACT,SAAS,CAAC,wBAAwB;AAAA,MAClC,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEM,SAAA;AACR;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,SAE5C,O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W,MAAM;AAAA,OAEnC,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,SACI,QAAQ,SAAS;AAAA,QAErB,OAAO;AAAA,MAAA;AAAA,IAGV;AAAA,EACD;AACD;"}
@@ -9,7 +9,7 @@ export default class SliceSimulator extends SvelteComponentTyped<{
9
9
  [evt: string]: CustomEvent<any>;
10
10
  }, {
11
11
  default: {
12
- slices: import("@prismicio/client/*").SliceZone;
12
+ slices: import("@prismicio/simulator/node_modules/@prismicio/client/*").SliceZone;
13
13
  };
14
14
  }> {
15
15
  }
@@ -28,7 +28,7 @@ declare const __propDef: {
28
28
  };
29
29
  slots: {
30
30
  default: {
31
- slices: import("@prismicio/client/*").SliceZone;
31
+ slices: import("@prismicio/simulator/node_modules/@prismicio/client/*").SliceZone;
32
32
  };
33
33
  };
34
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-sveltekit",
3
- "version": "0.3.50-alpha.dani-link-text-templates.1",
3
+ "version": "0.3.50-alpha.dani-link-snippets.1",
4
4
  "description": "Slice Machine adapter for SvelteKit.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -63,8 +63,8 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@prismicio/simulator": "^0.1.4",
66
- "@prismicio/types-internal": "^2.5.0",
67
- "@slicemachine/plugin-kit": "0.4.50-alpha.dani-link-text-templates.1",
66
+ "@prismicio/types-internal": "^2.8.0",
67
+ "@slicemachine/plugin-kit": "0.4.50-alpha.dani-link-snippets.1",
68
68
  "common-tags": "^1.8.2",
69
69
  "fp-ts": "^2.13.1",
70
70
  "io-ts": "^2.2.20",
@@ -61,9 +61,13 @@ export const snippetRead: SnippetReadHook<PluginOptions> = async (
61
61
  label,
62
62
  language: "svelte",
63
63
  code: await format(
64
- stripIndent`
65
- <PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>
66
- `,
64
+ data.model.config?.allowText
65
+ ? stripIndent`
66
+ <PrismicLink field={${dotPath(fieldPath)}} />
67
+ `
68
+ : stripIndent`
69
+ <PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>
70
+ `,
67
71
  helpers,
68
72
  ),
69
73
  };