@slicemachine/adapter-nuxt 0.3.92-beta.1 → 0.3.93-alpha.lh-nuxt-v5.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.
@@ -1,7 +1,5 @@
1
1
  <script setup>
2
- import { isFilled } from "@prismicio/client";
3
-
4
- defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
2
+ defineProps(getSliceComponentProps());
5
3
  </script>
6
4
 
7
5
  <template>
@@ -13,13 +11,13 @@ defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
13
11
  <div
14
12
  :class="[
15
13
  'es-alternate-grid__content',
16
- isFilled.image(slice.primary.image)
14
+ $prismic.isFilled.image(slice.primary.image)
17
15
  ? 'es-alternate-grid__content--with-image'
18
16
  : '',
19
17
  ]"
20
18
  >
21
19
  <PrismicImage
22
- v-if="isFilled.image(slice.primary.image)"
20
+ v-if="$prismic.isFilled.image(slice.primary.image)"
23
21
  :field="slice.primary.image"
24
22
  class="es-alternate-grid__image"
25
23
  :class="
@@ -31,19 +29,19 @@ defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
31
29
  <div class="es-alternate-grid__primary-content">
32
30
  <div className="es-alternate-grid__primary-content__intro">
33
31
  <div
34
- v-if="isFilled.keyText(slice.primary.eyebrowHeadline)"
32
+ v-if="$prismic.isFilled.keyText(slice.primary.eyebrowHeadline)"
35
33
  class="es-alternate-grid__primary-content__intro__eyebrow"
36
34
  >
37
35
  {{ slice.primary.eyebrowHeadline }}
38
36
  </div>
39
37
  <PrismicRichText
40
- v-if="isFilled.richText(slice.primary.title)"
38
+ v-if="$prismic.isFilled.richText(slice.primary.title)"
41
39
  :field="slice.primary.title"
42
40
  class="es-alternate-grid__primary-content__intro__headline"
43
41
  wrapper="div"
44
42
  />
45
43
  <PrismicRichText
46
- v-if="isFilled.richText(slice.primary.description)"
44
+ v-if="$prismic.isFilled.richText(slice.primary.description)"
47
45
  :field="slice.primary.description"
48
46
  class="es-alternate-grid__primary-content__intro__description"
49
47
  wrapper="div"
@@ -59,13 +57,13 @@ defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
59
57
  class="es-alternate-grid__item"
60
58
  >
61
59
  <PrismicRichText
62
- v-if="isFilled.richText(item.title)"
60
+ v-if="$prismic.isFilled.richText(item.title)"
63
61
  :field="item.title"
64
62
  class="es-alternate-grid__item__heading"
65
63
  wrapper="div"
66
64
  />
67
65
  <PrismicRichText
68
- v-if="isFilled.richText(item.description)"
66
+ v-if="$prismic.isFilled.richText(item.description)"
69
67
  :field="item.description"
70
68
  class="es-alternate-grid__item__description"
71
69
  wrapper="div"
@@ -1,14 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { type Content, isFilled } from "@prismicio/client";
3
-
4
- defineProps(
5
- getSliceComponentProps<Content.PascalNameToReplaceSlice>([
6
- "slice",
7
- "index",
8
- "slices",
9
- "context",
10
- ]),
11
- );
2
+ import type { Content } from "@prismicio/client";
3
+
4
+ defineProps(getSliceComponentProps<Content.PascalNameToReplaceSlice>());
12
5
  </script>
13
6
 
14
7
  <template>
@@ -20,13 +13,13 @@ defineProps(
20
13
  <div
21
14
  :class="[
22
15
  'es-alternate-grid__content',
23
- isFilled.image(slice.primary.image)
16
+ $prismic.isFilled.image(slice.primary.image)
24
17
  ? 'es-alternate-grid__content--with-image'
25
18
  : '',
26
19
  ]"
27
20
  >
28
21
  <PrismicImage
29
- v-if="isFilled.image(slice.primary.image)"
22
+ v-if="$prismic.isFilled.image(slice.primary.image)"
30
23
  :field="slice.primary.image"
31
24
  class="es-alternate-grid__image"
32
25
  :class="
@@ -38,19 +31,19 @@ defineProps(
38
31
  <div class="es-alternate-grid__primary-content">
39
32
  <div className="es-alternate-grid__primary-content__intro">
40
33
  <div
41
- v-if="isFilled.keyText(slice.primary.eyebrowHeadline)"
34
+ v-if="$prismic.isFilled.keyText(slice.primary.eyebrowHeadline)"
42
35
  class="es-alternate-grid__primary-content__intro__eyebrow"
43
36
  >
44
37
  {{ slice.primary.eyebrowHeadline }}
45
38
  </div>
46
39
  <PrismicRichText
47
- v-if="isFilled.richText(slice.primary.title)"
40
+ v-if="$prismic.isFilled.richText(slice.primary.title)"
48
41
  :field="slice.primary.title"
49
42
  class="es-alternate-grid__primary-content__intro__headline"
50
43
  wrapper="div"
51
44
  />
52
45
  <PrismicRichText
53
- v-if="isFilled.richText(slice.primary.description)"
46
+ v-if="$prismic.isFilled.richText(slice.primary.description)"
54
47
  :field="slice.primary.description"
55
48
  class="es-alternate-grid__primary-content__intro__description"
56
49
  wrapper="div"
@@ -66,13 +59,13 @@ defineProps(
66
59
  class="es-alternate-grid__item"
67
60
  >
68
61
  <PrismicRichText
69
- v-if="isFilled.richText(item.title)"
62
+ v-if="$prismic.isFilled.richText(item.title)"
70
63
  :field="item.title"
71
64
  class="es-alternate-grid__item__heading"
72
65
  wrapper="div"
73
66
  />
74
67
  <PrismicRichText
75
- v-if="isFilled.richText(item.description)"
68
+ v-if="$prismic.isFilled.richText(item.description)"
76
69
  :field="item.description"
77
70
  class="es-alternate-grid__item__description"
78
71
  wrapper="div"
@@ -1,9 +1,5 @@
1
1
  <script setup>
2
- import { isFilled } from "@prismicio/client";
3
-
4
- const props = defineProps(
5
- getSliceComponentProps(["slice", "index", "slices", "context"]),
6
- );
2
+ const props = defineProps(getSliceComponentProps());
7
3
 
8
4
  const alignment = computed(() => {
9
5
  return props.slice.variation === "alignLeft" ? "left" : "center";
@@ -18,19 +14,19 @@ const alignment = computed(() => {
18
14
  >
19
15
  <div class="es-bounded__content es-call-to-action__content">
20
16
  <PrismicImage
21
- v-if="isFilled.image(slice.primary.image)"
17
+ v-if="$prismic.isFilled.image(slice.primary.image)"
22
18
  :field="slice.primary.image"
23
19
  class="es-call-to-action__image"
24
20
  />
25
21
  <div class="es-call-to-action__content">
26
22
  <div
27
- v-if="isFilled.richText(slice.primary.title)"
23
+ v-if="$prismic.isFilled.richText(slice.primary.title)"
28
24
  class="es-call-to-action__content__heading"
29
25
  >
30
26
  <PrismicRichText :field="slice.primary.title" />
31
27
  </div>
32
28
  <div
33
- v-if="isFilled.richText(slice.primary.paragraph)"
29
+ v-if="$prismic.isFilled.richText(slice.primary.paragraph)"
34
30
  class="es-call-to-action__content__paragraph"
35
31
  >
36
32
  <PrismicRichText :field="slice.primary.paragraph" />
@@ -1,14 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { type Content, isFilled } from "@prismicio/client";
2
+ import type { Content } from "@prismicio/client";
3
3
 
4
- const props = defineProps(
5
- getSliceComponentProps<Content.PascalNameToReplaceSlice>([
6
- "slice",
7
- "index",
8
- "slices",
9
- "context",
10
- ]),
11
- );
4
+ const props = defineProps(getSliceComponentProps<Content.PascalNameToReplaceSlice>());
12
5
 
13
6
  const alignment = computed(() => {
14
7
  return props.slice.variation === "alignLeft" ? "left" : "center";
@@ -23,19 +16,19 @@ const alignment = computed(() => {
23
16
  >
24
17
  <div class="es-bounded__content es-call-to-action__content">
25
18
  <PrismicImage
26
- v-if="isFilled.image(slice.primary.image)"
19
+ v-if="$prismic.isFilled.image(slice.primary.image)"
27
20
  :field="slice.primary.image"
28
21
  class="es-call-to-action__image"
29
22
  />
30
23
  <div class="es-call-to-action__content">
31
24
  <div
32
- v-if="isFilled.richText(slice.primary.title)"
25
+ v-if="$prismic.isFilled.richText(slice.primary.title)"
33
26
  class="es-call-to-action__content__heading"
34
27
  >
35
28
  <PrismicRichText :field="slice.primary.title" />
36
29
  </div>
37
30
  <div
38
- v-if="isFilled.richText(slice.primary.paragraph)"
31
+ v-if="$prismic.isFilled.richText(slice.primary.paragraph)"
39
32
  class="es-call-to-action__content__paragraph"
40
33
  >
41
34
  <PrismicRichText :field="slice.primary.paragraph" />
@@ -1,7 +1,5 @@
1
1
  <script setup>
2
- import { isFilled } from "@prismicio/client";
3
-
4
- defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
2
+ defineProps(getSliceComponentProps());
5
3
  </script>
6
4
 
7
5
  <template>
@@ -12,7 +10,7 @@ defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
12
10
  >
13
11
  <div class="es-bounded__content es-customer-logos__content">
14
12
  <div
15
- v-if="isFilled.richText(slice.primary.eyebrowHeadline)"
13
+ v-if="$prismic.isFilled.richText(slice.primary.eyebrowHeadline)"
16
14
  class="es-customer-logos__heading"
17
15
  >
18
16
  <PrismicRichText :field="slice.primary.eyebrowHeadline" />
@@ -1,14 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { type Content, isFilled } from "@prismicio/client";
2
+ import type { Content } from "@prismicio/client";
3
3
 
4
- defineProps(
5
- getSliceComponentProps<Content.PascalNameToReplaceSlice>([
6
- "slice",
7
- "index",
8
- "slices",
9
- "context",
10
- ]),
11
- );
4
+ defineProps(getSliceComponentProps<Content.PascalNameToReplaceSlice>());
12
5
  </script>
13
6
 
14
7
  <template>
@@ -19,7 +12,7 @@ defineProps(
19
12
  >
20
13
  <div class="es-bounded__content es-customer-logos__content">
21
14
  <div
22
- v-if="isFilled.richText(slice.primary.eyebrowHeadline)"
15
+ v-if="$prismic.isFilled.richText(slice.primary.eyebrowHeadline)"
23
16
  class="es-customer-logos__heading"
24
17
  >
25
18
  <PrismicRichText :field="slice.primary.eyebrowHeadline" />
@@ -1,7 +1,5 @@
1
1
  <script setup>
2
- import { isFilled } from "@prismicio/client";
3
-
4
- defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
2
+ defineProps(getSliceComponentProps());
5
3
  </script>
6
4
 
7
5
  <template>
@@ -20,7 +18,7 @@ defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
20
18
  >
21
19
  <div>
22
20
  <PrismicImage
23
- v-if="isFilled.image(slice.primary.image)"
21
+ v-if="$prismic.isFilled.image(slice.primary.image)"
24
22
  :field="slice.primary.image"
25
23
  class="es-fullpage-hero__image"
26
24
  />
@@ -28,19 +26,19 @@ defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
28
26
  <div class="es-fullpage-hero__content-right">
29
27
  <div class="es-fullpage-hero__content__intro">
30
28
  <p
31
- v-if="isFilled.keyText(slice.primary.eyebrowHeadline)"
29
+ v-if="$prismic.isFilled.keyText(slice.primary.eyebrowHeadline)"
32
30
  class="es-fullpage-hero__content__intro__eyebrow"
33
31
  >
34
32
  {{ slice.primary.eyebrowHeadline }}
35
33
  </p>
36
34
  <div
37
- v-if="isFilled.richText(slice.primary.title)"
35
+ v-if="$prismic.isFilled.richText(slice.primary.title)"
38
36
  class="es-fullpage-hero__content__intro__headline"
39
37
  >
40
38
  <PrismicRichText :field="slice.primary.title" />
41
39
  </div>
42
40
  <div
43
- v-if="isFilled.richText(slice.primary.description)"
41
+ v-if="$prismic.isFilled.richText(slice.primary.description)"
44
42
  class="es-fullpage-hero__content__intro__description"
45
43
  >
46
44
  <PrismicRichText :field="slice.primary.description" />
@@ -1,14 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { type Content, isFilled } from "@prismicio/client";
3
-
4
- defineProps(
5
- getSliceComponentProps<Content.PascalNameToReplaceSlice>([
6
- "slice",
7
- "index",
8
- "slices",
9
- "context",
10
- ]),
11
- );
2
+ import type { Content } from "@prismicio/client";
3
+
4
+ defineProps(getSliceComponentProps<Content.PascalNameToReplaceSlice>());
12
5
  </script>
13
6
 
14
7
  <template>
@@ -27,7 +20,7 @@ defineProps(
27
20
  >
28
21
  <div>
29
22
  <PrismicImage
30
- v-if="isFilled.image(slice.primary.image)"
23
+ v-if="$prismic.isFilled.image(slice.primary.image)"
31
24
  :field="slice.primary.image"
32
25
  class="es-fullpage-hero__image"
33
26
  />
@@ -35,19 +28,19 @@ defineProps(
35
28
  <div class="es-fullpage-hero__content-right">
36
29
  <div class="es-fullpage-hero__content__intro">
37
30
  <p
38
- v-if="isFilled.keyText(slice.primary.eyebrowHeadline)"
31
+ v-if="$prismic.isFilled.keyText(slice.primary.eyebrowHeadline)"
39
32
  class="es-fullpage-hero__content__intro__eyebrow"
40
33
  >
41
34
  {{ slice.primary.eyebrowHeadline }}
42
35
  </p>
43
36
  <div
44
- v-if="isFilled.richText(slice.primary.title)"
37
+ v-if="$prismic.isFilled.richText(slice.primary.title)"
45
38
  class="es-fullpage-hero__content__intro__headline"
46
39
  >
47
40
  <PrismicRichText :field="slice.primary.title" />
48
41
  </div>
49
42
  <div
50
- v-if="isFilled.richText(slice.primary.description)"
43
+ v-if="$prismic.isFilled.richText(slice.primary.description)"
51
44
  class="es-fullpage-hero__content__intro__description"
52
45
  >
53
46
  <PrismicRichText :field="slice.primary.description" />
@@ -20,9 +20,9 @@ const documentationRead = async (data, { options, helpers }) => {
20
20
  }
21
21
  let fileContent;
22
22
  if (model.repeatable) {
23
- fileContent = commonTags.stripIndent(_a || (_a = __template(["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const route = useRoute();\n const { data: page } = await useAsyncData(`[', '-uid-${route.params.uid}]`, () =>\n prismic.client.getByUID("', '", route.params.uid', ')\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '], ["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const route = useRoute();\n const { data: page } = await useAsyncData(\\`[', '-uid-\\${route.params.uid}]\\`, () =>\n prismic.client.getByUID("', '", route.params.uid', ')\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id, isTypeScriptProject ? " as string" : "");
23
+ fileContent = commonTags.stripIndent(_a || (_a = __template(["\n <script ", '>\n import { asImageSrc } from "@prismicio/client";\n import { components } from "~/slices";\n\n const route = useRoute();\n const { client } = usePrismic();\n const { data: page } = await useAsyncData(`[', '-uid-${route.params.uid}]`, () =>\n client.getByUID("', '", route.params.uid', ')\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <main>\n <SliceZone :slices="page?.data.slices ?? []" :components="components" />\n </main>\n </template>\n '], ["\n <script ", '>\n import { asImageSrc } from "@prismicio/client";\n import { components } from "~/slices";\n\n const route = useRoute();\n const { client } = usePrismic();\n const { data: page } = await useAsyncData(\\`[', '-uid-\\${route.params.uid}]\\`, () =>\n client.getByUID("', '", route.params.uid', ')\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <main>\n <SliceZone :slices="page?.data.slices ?? []" :components="components" />\n </main>\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id, isTypeScriptProject ? " as string" : "");
24
24
  } else {
25
- fileContent = commonTags.stripIndent(_b || (_b = __template(["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const { data: page } = await useAsyncData("[', ']", () =>\n prismic.client.getSingle("', '")\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id);
25
+ fileContent = commonTags.stripIndent(_b || (_b = __template(["\n <script ", '>\n import { asImageSrc } from "@prismicio/client";\n import { components } from "~/slices";\n\n const { client } = usePrismic();\n const { data: page } = await useAsyncData("[', ']", () =>\n client.getSingle("', '")\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <main>\n <SliceZone :slices="page?.data.slices ?? []" :components="components" />\n </main>\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id);
26
26
  }
27
27
  if (options.format) {
28
28
  fileContent = await helpers.format(fileContent, helpers.joinPathFromRoot("index.vue"), {
@@ -1 +1 @@
1
- {"version":3,"file":"documentation-read.cjs","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source, stripIndent } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\t\tconst filePath = `${model.repeatable ? \"[uid]\" : model.id}.vue`;\n\t\tconst scriptAttributes = [\"setup\"];\n\t\tif (isTypeScriptProject) {\n\t\t\tscriptAttributes.push('lang=\"ts\"');\n\t\t}\n\n\t\tlet fileContent: string;\n\n\t\tif (model.repeatable) {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst prismic = usePrismic();\n\t\t\t\tconst route = useRoute();\n\t\t\t\tconst { data: page } = await useAsyncData(\\`[${\n\t\t\t\t\tmodel.id\n\t\t\t\t}-uid-\\${route.params.uid}]\\`, () =>\n\t\t\t\t\tprismic.client.getByUID(\"${model.id}\", route.params.uid${\n\t\t\t\t\t\tisTypeScriptProject ? \" as string\" : \"\"\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tuseSeoMeta({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\togTitle: page.value?.data.meta_title,\n\t\t\t\t\tdescription: page.value?.data.meta_description,\n\t\t\t\t\togDescription: page.value?.data.meta_description,\n\t\t\t\t\togImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\twrapper=\"main\"\n\t\t\t\t\t\t:slices=\"page?.data.slices ?? []\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t} else {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst prismic = usePrismic();\n\t\t\t\tconst { data: page } = await useAsyncData(\"[${model.id}]\", () =>\n\t\t\t\t\tprismic.client.getSingle(\"${model.id}\")\n\t\t\t\t);\n\n\t\t\t\tuseSeoMeta({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\togTitle: page.value?.data.meta_title,\n\t\t\t\t\tdescription: page.value?.data.meta_description,\n\t\t\t\t\togDescription: page.value?.data.meta_description,\n\t\t\t\t\togImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\twrapper=\"main\"\n\t\t\t\t\t\t:slices=\"page?.data.slices ?? []\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t}\n\n\t\tif (options.format) {\n\t\t\tfileContent = await helpers.format(\n\t\t\t\tfileContent,\n\t\t\t\thelpers.joinPathFromRoot(\"index.vue\"),\n\t\t\t\t{\n\t\t\t\t\tprettier: { parser: \"vue\" },\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Composition API\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tAdd a new route by creating an \\`~/pages/${filePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`~/pages/marketing/${filePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~vue [~/pages/${filePath}]\\n${fileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt#set-up-a-nuxt-website) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":["checkIsTypeScriptProject","stripIndent","source"],"mappings":";;;;;;;AAAA,IAAA,IAAA;AAOO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACH,QAAM,sBAAsB,MAAMA,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,KAAK,SAAS,eAAe;AAChC,UAAM,EAAE,UAAU,KAAK;AACvB,UAAM,WAAW,GAAG,MAAM,aAAa,UAAU,MAAM,EAAE;AACzD,UAAM,mBAAmB,CAAC,OAAO;AACjC,QAAI,qBAAqB;AACxB,uBAAiB,KAAK,WAAW;AAAA,IAClC;AAEA,QAAI;AAEJ,QAAI,MAAM,YAAY;AACrB,oBAAcC,WAAAA,YAAA,OAAA,KAAW,8BACY,uKAOpC,qEACoC,uBAEnC,6eAAA,GAXuB,CAAA,kBACY,yKAOpC,yEACoC,uBAEnC,kfAVS,iBAAiB,KAAK,GAAG,GAMlC,MAAM,IAEqB,MAAM,IAChC,sBAAsB,eAAe,EAAA;AAAA,IAqBzC,OAAO;AACN,oBAAcA,WAAAA,YAAA,OAAA,KAAW,WAAA,CAAA,kBACY,wIAIkB,8CACjB,8eAAA,CAAA,IAL3B,iBAAiB,KAAK,GAAG,GAIW,MAAM,IACvB,MAAM,EAAA;AAAA,IAoBrC;AAEA,QAAI,QAAQ,QAAQ;AACnB,oBAAc,MAAM,QAAQ,OAC3B,aACA,QAAQ,iBAAiB,WAAW,GACpC;AAAA,QACC,UAAU,EAAE,QAAQ,MAAA;AAAA,QACpB,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEH;AAEA,WAAO;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAASC,WAAAA;AAAAA,sBACS,MAAM,KAAK;AAAA;AAAA,gDAEe,QAAQ,kIAAkI,QAAQ;AAAA;AAAA;AAAA;AAAA,OAI3L,mBAAmB,QAAQ;AAAA,EAAM,WAAW;AAAA,IAAO;AAAA;AAAA;AAAA;AAAA,MAAA;AAAA,IAItD;AAAA,EAEH;AAEA,SAAO,CAAA;AACR;;"}
1
+ {"version":3,"file":"documentation-read.cjs","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source, stripIndent } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\t\tconst filePath = `${model.repeatable ? \"[uid]\" : model.id}.vue`;\n\t\tconst scriptAttributes = [\"setup\"];\n\t\tif (isTypeScriptProject) {\n\t\t\tscriptAttributes.push('lang=\"ts\"');\n\t\t}\n\n\t\tlet fileContent: string;\n\n\t\tif (model.repeatable) {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { asImageSrc } from \"@prismicio/client\";\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst route = useRoute();\n\t\t\t\tconst { client } = usePrismic();\n\t\t\t\tconst { data: page } = await useAsyncData(\\`[${\n\t\t\t\t\tmodel.id\n\t\t\t\t}-uid-\\${route.params.uid}]\\`, () =>\n\t\t\t\t\tclient.getByUID(\"${model.id}\", route.params.uid${\n\t\t\t\t\t\tisTypeScriptProject ? \" as string\" : \"\"\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tuseSeoMeta({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\togTitle: page.value?.data.meta_title,\n\t\t\t\t\tdescription: page.value?.data.meta_description,\n\t\t\t\t\togDescription: page.value?.data.meta_description,\n\t\t\t\t\togImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<main>\n\t\t\t\t\t\t<SliceZone :slices=\"page?.data.slices ?? []\" :components=\"components\" />\n\t\t\t\t\t</main>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t} else {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { asImageSrc } from \"@prismicio/client\";\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst { client } = usePrismic();\n\t\t\t\tconst { data: page } = await useAsyncData(\"[${model.id}]\", () =>\n\t\t\t\t\tclient.getSingle(\"${model.id}\")\n\t\t\t\t);\n\n\t\t\t\tuseSeoMeta({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\togTitle: page.value?.data.meta_title,\n\t\t\t\t\tdescription: page.value?.data.meta_description,\n\t\t\t\t\togDescription: page.value?.data.meta_description,\n\t\t\t\t\togImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<main>\n\t\t\t\t\t\t<SliceZone :slices=\"page?.data.slices ?? []\" :components=\"components\" />\n\t\t\t\t\t</main>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t}\n\n\t\tif (options.format) {\n\t\t\tfileContent = await helpers.format(\n\t\t\t\tfileContent,\n\t\t\t\thelpers.joinPathFromRoot(\"index.vue\"),\n\t\t\t\t{\n\t\t\t\t\tprettier: { parser: \"vue\" },\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Composition API\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tAdd a new route by creating an \\`~/pages/${filePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`~/pages/marketing/${filePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~vue [~/pages/${filePath}]\\n${fileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt#set-up-a-nuxt-website) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":["checkIsTypeScriptProject","stripIndent","source"],"mappings":";;;;;;;AAAA,IAAA,IAAA;AAOO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACH,QAAM,sBAAsB,MAAMA,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,KAAK,SAAS,eAAe;AAChC,UAAM,EAAE,UAAU,KAAK;AACvB,UAAM,WAAW,GAAG,MAAM,aAAa,UAAU,MAAM,EAAE;AACzD,UAAM,mBAAmB,CAAC,OAAO;AACjC,QAAI,qBAAqB;AACxB,uBAAiB,KAAK,WAAW;AAAA,IAClC;AAEA,QAAI;AAEJ,QAAI,MAAM,YAAY;AACrB,oBAAcC,WAAAA,YAAA,OAAA,KAAW,8BACY,+NAQpC,6DAC4B,uBAE3B,udAAA,GAZuB,CAAA,kBACY,iOAQpC,iEAC4B,uBAE3B,4dAXS,iBAAiB,KAAK,GAAG,GAOlC,MAAM,IAEa,MAAM,IACxB,sBAAsB,eAAe,EAAA;AAAA,IAmBzC,OAAO;AACN,oBAAcA,WAAAA,YAAA,OAAA,KAAW,WAAA,CAAA,kBACY,gMAKkB,sCACzB,wdAAA,CAAA,IANnB,iBAAiB,KAAK,GAAG,GAKW,MAAM,IAC/B,MAAM,EAAA;AAAA,IAkB7B;AAEA,QAAI,QAAQ,QAAQ;AACnB,oBAAc,MAAM,QAAQ,OAC3B,aACA,QAAQ,iBAAiB,WAAW,GACpC;AAAA,QACC,UAAU,EAAE,QAAQ,MAAA;AAAA,QACpB,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEH;AAEA,WAAO;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAASC,WAAAA;AAAAA,sBACS,MAAM,KAAK;AAAA;AAAA,gDAEe,QAAQ,kIAAkI,QAAQ;AAAA;AAAA;AAAA;AAAA,OAI3L,mBAAmB,QAAQ;AAAA,EAAM,WAAW;AAAA,IAAO;AAAA;AAAA;AAAA;AAAA,MAAA;AAAA,IAItD;AAAA,EAEH;AAEA,SAAO,CAAA;AACR;;"}
@@ -18,9 +18,9 @@ const documentationRead = async (data, { options, helpers }) => {
18
18
  }
19
19
  let fileContent;
20
20
  if (model.repeatable) {
21
- fileContent = stripIndent(_a || (_a = __template(["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const route = useRoute();\n const { data: page } = await useAsyncData(`[', '-uid-${route.params.uid}]`, () =>\n prismic.client.getByUID("', '", route.params.uid', ')\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '], ["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const route = useRoute();\n const { data: page } = await useAsyncData(\\`[', '-uid-\\${route.params.uid}]\\`, () =>\n prismic.client.getByUID("', '", route.params.uid', ')\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id, isTypeScriptProject ? " as string" : "");
21
+ fileContent = stripIndent(_a || (_a = __template(["\n <script ", '>\n import { asImageSrc } from "@prismicio/client";\n import { components } from "~/slices";\n\n const route = useRoute();\n const { client } = usePrismic();\n const { data: page } = await useAsyncData(`[', '-uid-${route.params.uid}]`, () =>\n client.getByUID("', '", route.params.uid', ')\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <main>\n <SliceZone :slices="page?.data.slices ?? []" :components="components" />\n </main>\n </template>\n '], ["\n <script ", '>\n import { asImageSrc } from "@prismicio/client";\n import { components } from "~/slices";\n\n const route = useRoute();\n const { client } = usePrismic();\n const { data: page } = await useAsyncData(\\`[', '-uid-\\${route.params.uid}]\\`, () =>\n client.getByUID("', '", route.params.uid', ')\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <main>\n <SliceZone :slices="page?.data.slices ?? []" :components="components" />\n </main>\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id, isTypeScriptProject ? " as string" : "");
22
22
  } else {
23
- fileContent = stripIndent(_b || (_b = __template(["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const { data: page } = await useAsyncData("[', ']", () =>\n prismic.client.getSingle("', '")\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id);
23
+ fileContent = stripIndent(_b || (_b = __template(["\n <script ", '>\n import { asImageSrc } from "@prismicio/client";\n import { components } from "~/slices";\n\n const { client } = usePrismic();\n const { data: page } = await useAsyncData("[', ']", () =>\n client.getSingle("', '")\n );\n\n useSeoMeta({\n title: page.value?.data.meta_title,\n ogTitle: page.value?.data.meta_title,\n description: page.value?.data.meta_description,\n ogDescription: page.value?.data.meta_description,\n ogImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n });\n <\/script>\n\n <template>\n <main>\n <SliceZone :slices="page?.data.slices ?? []" :components="components" />\n </main>\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id);
24
24
  }
25
25
  if (options.format) {
26
26
  fileContent = await helpers.format(fileContent, helpers.joinPathFromRoot("index.vue"), {
@@ -1 +1 @@
1
- {"version":3,"file":"documentation-read.js","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source, stripIndent } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\t\tconst filePath = `${model.repeatable ? \"[uid]\" : model.id}.vue`;\n\t\tconst scriptAttributes = [\"setup\"];\n\t\tif (isTypeScriptProject) {\n\t\t\tscriptAttributes.push('lang=\"ts\"');\n\t\t}\n\n\t\tlet fileContent: string;\n\n\t\tif (model.repeatable) {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst prismic = usePrismic();\n\t\t\t\tconst route = useRoute();\n\t\t\t\tconst { data: page } = await useAsyncData(\\`[${\n\t\t\t\t\tmodel.id\n\t\t\t\t}-uid-\\${route.params.uid}]\\`, () =>\n\t\t\t\t\tprismic.client.getByUID(\"${model.id}\", route.params.uid${\n\t\t\t\t\t\tisTypeScriptProject ? \" as string\" : \"\"\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tuseSeoMeta({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\togTitle: page.value?.data.meta_title,\n\t\t\t\t\tdescription: page.value?.data.meta_description,\n\t\t\t\t\togDescription: page.value?.data.meta_description,\n\t\t\t\t\togImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\twrapper=\"main\"\n\t\t\t\t\t\t:slices=\"page?.data.slices ?? []\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t} else {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst prismic = usePrismic();\n\t\t\t\tconst { data: page } = await useAsyncData(\"[${model.id}]\", () =>\n\t\t\t\t\tprismic.client.getSingle(\"${model.id}\")\n\t\t\t\t);\n\n\t\t\t\tuseSeoMeta({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\togTitle: page.value?.data.meta_title,\n\t\t\t\t\tdescription: page.value?.data.meta_description,\n\t\t\t\t\togDescription: page.value?.data.meta_description,\n\t\t\t\t\togImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\twrapper=\"main\"\n\t\t\t\t\t\t:slices=\"page?.data.slices ?? []\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t}\n\n\t\tif (options.format) {\n\t\t\tfileContent = await helpers.format(\n\t\t\t\tfileContent,\n\t\t\t\thelpers.joinPathFromRoot(\"index.vue\"),\n\t\t\t\t{\n\t\t\t\t\tprettier: { parser: \"vue\" },\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Composition API\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tAdd a new route by creating an \\`~/pages/${filePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`~/pages/marketing/${filePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~vue [~/pages/${filePath}]\\n${fileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt#set-up-a-nuxt-website) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":[],"mappings":";;;;;AAAA,IAAA,IAAA;AAOO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACH,QAAM,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,KAAK,SAAS,eAAe;AAChC,UAAM,EAAE,UAAU,KAAK;AACvB,UAAM,WAAW,GAAG,MAAM,aAAa,UAAU,MAAM,EAAE;AACzD,UAAM,mBAAmB,CAAC,OAAO;AACjC,QAAI,qBAAqB;AACxB,uBAAiB,KAAK,WAAW;AAAA,IAClC;AAEA,QAAI;AAEJ,QAAI,MAAM,YAAY;AACrB,oBAAc,YAAA,OAAA,KAAW,8BACY,uKAOpC,qEACoC,uBAEnC,6eAAA,GAXuB,CAAA,kBACY,yKAOpC,yEACoC,uBAEnC,kfAVS,iBAAiB,KAAK,GAAG,GAMlC,MAAM,IAEqB,MAAM,IAChC,sBAAsB,eAAe,EAAA;AAAA,IAqBzC,OAAO;AACN,oBAAc,YAAA,OAAA,KAAW,WAAA,CAAA,kBACY,wIAIkB,8CACjB,8eAAA,CAAA,IAL3B,iBAAiB,KAAK,GAAG,GAIW,MAAM,IACvB,MAAM,EAAA;AAAA,IAoBrC;AAEA,QAAI,QAAQ,QAAQ;AACnB,oBAAc,MAAM,QAAQ,OAC3B,aACA,QAAQ,iBAAiB,WAAW,GACpC;AAAA,QACC,UAAU,EAAE,QAAQ,MAAA;AAAA,QACpB,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEH;AAEA,WAAO;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAAS;AAAA,sBACS,MAAM,KAAK;AAAA;AAAA,gDAEe,QAAQ,kIAAkI,QAAQ;AAAA;AAAA;AAAA;AAAA,OAI3L,mBAAmB,QAAQ;AAAA,EAAM,WAAW;AAAA,IAAO;AAAA;AAAA;AAAA;AAAA,MAAA;AAAA,IAItD;AAAA,EAEH;AAEA,SAAO,CAAA;AACR;"}
1
+ {"version":3,"file":"documentation-read.js","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source, stripIndent } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\t\tconst filePath = `${model.repeatable ? \"[uid]\" : model.id}.vue`;\n\t\tconst scriptAttributes = [\"setup\"];\n\t\tif (isTypeScriptProject) {\n\t\t\tscriptAttributes.push('lang=\"ts\"');\n\t\t}\n\n\t\tlet fileContent: string;\n\n\t\tif (model.repeatable) {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { asImageSrc } from \"@prismicio/client\";\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst route = useRoute();\n\t\t\t\tconst { client } = usePrismic();\n\t\t\t\tconst { data: page } = await useAsyncData(\\`[${\n\t\t\t\t\tmodel.id\n\t\t\t\t}-uid-\\${route.params.uid}]\\`, () =>\n\t\t\t\t\tclient.getByUID(\"${model.id}\", route.params.uid${\n\t\t\t\t\t\tisTypeScriptProject ? \" as string\" : \"\"\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tuseSeoMeta({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\togTitle: page.value?.data.meta_title,\n\t\t\t\t\tdescription: page.value?.data.meta_description,\n\t\t\t\t\togDescription: page.value?.data.meta_description,\n\t\t\t\t\togImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<main>\n\t\t\t\t\t\t<SliceZone :slices=\"page?.data.slices ?? []\" :components=\"components\" />\n\t\t\t\t\t</main>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t} else {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { asImageSrc } from \"@prismicio/client\";\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst { client } = usePrismic();\n\t\t\t\tconst { data: page } = await useAsyncData(\"[${model.id}]\", () =>\n\t\t\t\t\tclient.getSingle(\"${model.id}\")\n\t\t\t\t);\n\n\t\t\t\tuseSeoMeta({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\togTitle: page.value?.data.meta_title,\n\t\t\t\t\tdescription: page.value?.data.meta_description,\n\t\t\t\t\togDescription: page.value?.data.meta_description,\n\t\t\t\t\togImage: computed(() => asImageSrc(page.value?.data.meta_image)),\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<main>\n\t\t\t\t\t\t<SliceZone :slices=\"page?.data.slices ?? []\" :components=\"components\" />\n\t\t\t\t\t</main>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t}\n\n\t\tif (options.format) {\n\t\t\tfileContent = await helpers.format(\n\t\t\t\tfileContent,\n\t\t\t\thelpers.joinPathFromRoot(\"index.vue\"),\n\t\t\t\t{\n\t\t\t\t\tprettier: { parser: \"vue\" },\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Composition API\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tAdd a new route by creating an \\`~/pages/${filePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`~/pages/marketing/${filePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~vue [~/pages/${filePath}]\\n${fileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt#set-up-a-nuxt-website) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":[],"mappings":";;;;;AAAA,IAAA,IAAA;AAOO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACH,QAAM,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,KAAK,SAAS,eAAe;AAChC,UAAM,EAAE,UAAU,KAAK;AACvB,UAAM,WAAW,GAAG,MAAM,aAAa,UAAU,MAAM,EAAE;AACzD,UAAM,mBAAmB,CAAC,OAAO;AACjC,QAAI,qBAAqB;AACxB,uBAAiB,KAAK,WAAW;AAAA,IAClC;AAEA,QAAI;AAEJ,QAAI,MAAM,YAAY;AACrB,oBAAc,YAAA,OAAA,KAAW,8BACY,+NAQpC,6DAC4B,uBAE3B,udAAA,GAZuB,CAAA,kBACY,iOAQpC,iEAC4B,uBAE3B,4dAXS,iBAAiB,KAAK,GAAG,GAOlC,MAAM,IAEa,MAAM,IACxB,sBAAsB,eAAe,EAAA;AAAA,IAmBzC,OAAO;AACN,oBAAc,YAAA,OAAA,KAAW,WAAA,CAAA,kBACY,gMAKkB,sCACzB,wdAAA,CAAA,IANnB,iBAAiB,KAAK,GAAG,GAKW,MAAM,IAC/B,MAAM,EAAA;AAAA,IAkB7B;AAEA,QAAI,QAAQ,QAAQ;AACnB,oBAAc,MAAM,QAAQ,OAC3B,aACA,QAAQ,iBAAiB,WAAW,GACpC;AAAA,QACC,UAAU,EAAE,QAAQ,MAAA;AAAA,QACpB,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEH;AAEA,WAAO;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAAS;AAAA,sBACS,MAAM,KAAK;AAAA;AAAA,gDAEe,QAAQ,kIAAkI,QAAQ;AAAA;AAAA;AAAA;AAAA,OAI3L,mBAAmB,QAAQ;AAAA,EAAM,WAAW;AAAA,IAAO;AAAA;AAAA;AAAA;AAAA,MAAA;AAAA,IAItD;AAAA,EAEH;AAEA,SAAO,CAAA;AACR;"}
@@ -8,7 +8,7 @@ const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
8
8
  const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
9
9
  var __freeze = Object.freeze;
10
10
  var __defProp = Object.defineProperty;
11
- var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
11
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(cooked.slice()) }));
12
12
  var _a, _b;
13
13
  const createComponentFile = async ({ data, helpers, actions, options }) => {
14
14
  const pascalName = pascalCase.pascalCase(data.model.name);
@@ -27,9 +27,9 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
27
27
  if (data.componentContents) {
28
28
  contents = data.componentContents;
29
29
  } else if (isTypeScriptProject) {
30
- contents = commonTags.stripIndent(_a || (_a = __template(['\n <script setup lang="ts">\n import type { Content } from "@prismicio/client";\n\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) slices.\n ", "\n </section>\n </template>\n "], ['\n <script setup lang="ts">\n import type { Content } from "@prismicio/client";\n\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) slices.\n ", "\n </section>\n </template>\n "])), pascalName, data.model.id, placeholderInstructions);
30
+ contents = commonTags.stripIndent(_a || (_a = __template(['\n <script setup lang="ts">\n import type { Content } from "@prismicio/client";\n\n defineProps(getSliceComponentProps<Content.', 'Slice>());\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) slices.\n ", "\n </section>\n </template>\n "])), pascalName, data.model.id, placeholderInstructions);
31
31
  } else {
32
- contents = commonTags.stripIndent(_b || (_b = __template(['\n <script setup>\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n ', "\n </section>\n </template>\n "], ['\n <script setup>\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n ', "\n </section>\n </template>\n "])), placeholderInstructions);
32
+ contents = commonTags.stripIndent(_b || (_b = __template(['\n <script setup>\n defineProps(getSliceComponentProps());\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n ', "\n </section>\n </template>\n "])), placeholderInstructions);
33
33
  }
34
34
  await fs.writeSliceFile({
35
35
  libraryID: data.libraryID,
@@ -1 +1 @@
1
- {"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype CreateComponentFileArgs = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: CreateComponentFileArgs) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst placeholderInstructions = `\n\t\t<br />\n\t\t<strong>You can edit this slice directly in your code editor.</strong>\n\t\t<!--\n\t\t\t💡 Use the Prismic MCP server with your code editor\n\t\t\t📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server\n\t\t-->`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport type { Content } from \"@prismicio/client\";\n\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>(\n\t\t\t\t[\"slice\", \"index\", \"slices\", \"context\"]\n\t\t\t));\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${data.model.id} (variation: {{ slice.variation }}) slices.\n\t\t\t\t\t${placeholderInstructions}\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<script setup>\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]));\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n\t\t\t\t\t${placeholderInstructions}\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.vue\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":["pascalCase","checkIsTypeScriptProject","stripIndent","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cAC6B;AAC7B,QAAM,aAAaA,WAAAA,WAAW,KAAK,MAAM,IAAI;AAE7C,MAAI;AAEJ,QAAM,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQhC,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,EACjB,WAAW,qBAAqB;AAC/B,eAAWC,WAAAA,YAAA,OAAA,KAAW,WAAA,CAAA,yRAMkC,8OAUZ,sDAChB,sCAAA,GAjBN,CAAA,6RAMkC,8OAUZ,sDAChB,sCAAA,CAAA,IAXkB,YAUf,KAAK,MAAM,IACrC,uBAAA;AAAA,EAIN,OAAO;AACN,eAAWA,WAAAA,YAAA,OAAA,KAAW,WAAA,CAAA,ueAaM,sCAAA,GAbN,CAAA,2eAaM,sCAAA,CAAA,IAAvB,uBAAA;AAAA,EAIN;AAEA,QAAMC,kBAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACA;AACF;AAEO,MAAM,cAA8C,OAC1D,MACA,YACG;AACHC,sCACC,MAAM,QAAQ,WAAW;AAAA,IACxBC,mBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EAAA,CACxC,CAAC;AAGHD,sCACC,MAAM,QAAQ,WAAW;AAAA,IACxBE,wDAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACDC,+BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EAAA,CACD,CAAC;AAEJ;;"}
1
+ {"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype CreateComponentFileArgs = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: CreateComponentFileArgs) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst placeholderInstructions = `\n\t\t<br />\n\t\t<strong>You can edit this slice directly in your code editor.</strong>\n\t\t<!--\n\t\t\t💡 Use the Prismic MCP server with your code editor\n\t\t\t📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server\n\t\t-->`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport type { Content } from \"@prismicio/client\";\n\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>());\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${data.model.id} (variation: {{ slice.variation }}) slices.\n\t\t\t\t\t${placeholderInstructions}\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<script setup>\n\t\t\tdefineProps(getSliceComponentProps());\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n\t\t\t\t\t${placeholderInstructions}\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.vue\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":["pascalCase","checkIsTypeScriptProject","stripIndent","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cAC6B;AAC7B,QAAM,aAAaA,WAAAA,WAAW,KAAK,MAAM,IAAI;AAE7C,MAAI;AAEJ,QAAM,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQhC,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,EACjB,WAAW,qBAAqB;AAC/B,eAAWC,WAAAA,YAAA,OAAA,KAAW,qJAIkC,4LAQZ,sDAChB,2CATkB,YAQf,KAAK,MAAM,IACrC,uBAAA;AAAA,EAIN,OAAO;AACN,eAAWA,WAAAA,YAAA,OAAA,KAAW,4TAWM,sCAAA,CAAA,IAAvB,uBAAA;AAAA,EAIN;AAEA,QAAMC,kBAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACA;AACF;AAEO,MAAM,cAA8C,OAC1D,MACA,YACG;AACHC,sCACC,MAAM,QAAQ,WAAW;AAAA,IACxBC,mBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EAAA,CACxC,CAAC;AAGHD,sCACC,MAAM,QAAQ,WAAW;AAAA,IACxBE,wDAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACDC,+BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EAAA,CACD,CAAC;AAEJ;;"}
@@ -6,7 +6,7 @@ import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
6
6
  import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
7
7
  var __freeze = Object.freeze;
8
8
  var __defProp = Object.defineProperty;
9
- var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
9
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(cooked.slice()) }));
10
10
  var _a, _b;
11
11
  const createComponentFile = async ({ data, helpers, actions, options }) => {
12
12
  const pascalName = pascalCase(data.model.name);
@@ -25,9 +25,9 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
25
25
  if (data.componentContents) {
26
26
  contents = data.componentContents;
27
27
  } else if (isTypeScriptProject) {
28
- contents = stripIndent(_a || (_a = __template(['\n <script setup lang="ts">\n import type { Content } from "@prismicio/client";\n\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) slices.\n ", "\n </section>\n </template>\n "], ['\n <script setup lang="ts">\n import type { Content } from "@prismicio/client";\n\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) slices.\n ", "\n </section>\n </template>\n "])), pascalName, data.model.id, placeholderInstructions);
28
+ contents = stripIndent(_a || (_a = __template(['\n <script setup lang="ts">\n import type { Content } from "@prismicio/client";\n\n defineProps(getSliceComponentProps<Content.', 'Slice>());\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) slices.\n ", "\n </section>\n </template>\n "])), pascalName, data.model.id, placeholderInstructions);
29
29
  } else {
30
- contents = stripIndent(_b || (_b = __template(['\n <script setup>\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n ', "\n </section>\n </template>\n "], ['\n <script setup>\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n ', "\n </section>\n </template>\n "])), placeholderInstructions);
30
+ contents = stripIndent(_b || (_b = __template(['\n <script setup>\n defineProps(getSliceComponentProps());\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n ', "\n </section>\n </template>\n "])), placeholderInstructions);
31
31
  }
32
32
  await writeSliceFile({
33
33
  libraryID: data.libraryID,
@@ -1 +1 @@
1
- {"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype CreateComponentFileArgs = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: CreateComponentFileArgs) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst placeholderInstructions = `\n\t\t<br />\n\t\t<strong>You can edit this slice directly in your code editor.</strong>\n\t\t<!--\n\t\t\t💡 Use the Prismic MCP server with your code editor\n\t\t\t📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server\n\t\t-->`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport type { Content } from \"@prismicio/client\";\n\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>(\n\t\t\t\t[\"slice\", \"index\", \"slices\", \"context\"]\n\t\t\t));\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${data.model.id} (variation: {{ slice.variation }}) slices.\n\t\t\t\t\t${placeholderInstructions}\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<script setup>\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]));\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n\t\t\t\t\t${placeholderInstructions}\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.vue\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cAC6B;AAC7B,QAAM,aAAa,WAAW,KAAK,MAAM,IAAI;AAE7C,MAAI;AAEJ,QAAM,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQhC,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,EACjB,WAAW,qBAAqB;AAC/B,eAAW,YAAA,OAAA,KAAW,WAAA,CAAA,yRAMkC,8OAUZ,sDAChB,sCAAA,GAjBN,CAAA,6RAMkC,8OAUZ,sDAChB,sCAAA,CAAA,IAXkB,YAUf,KAAK,MAAM,IACrC,uBAAA;AAAA,EAIN,OAAO;AACN,eAAW,YAAA,OAAA,KAAW,WAAA,CAAA,ueAaM,sCAAA,GAbN,CAAA,2eAaM,sCAAA,CAAA,IAAvB,uBAAA;AAAA,EAIN;AAEA,QAAM,eAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACA;AACF;AAEO,MAAM,cAA8C,OAC1D,MACA,YACG;AACH,oBACC,MAAM,QAAQ,WAAW;AAAA,IACxB,gBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EAAA,CACxC,CAAC;AAGH,oBACC,MAAM,QAAQ,WAAW;AAAA,IACxB,4BAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACD,4BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EAAA,CACD,CAAC;AAEJ;"}
1
+ {"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype CreateComponentFileArgs = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: CreateComponentFileArgs) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst placeholderInstructions = `\n\t\t<br />\n\t\t<strong>You can edit this slice directly in your code editor.</strong>\n\t\t<!--\n\t\t\t💡 Use the Prismic MCP server with your code editor\n\t\t\t📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server\n\t\t-->`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport type { Content } from \"@prismicio/client\";\n\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>());\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${data.model.id} (variation: {{ slice.variation }}) slices.\n\t\t\t\t\t${placeholderInstructions}\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<script setup>\n\t\t\tdefineProps(getSliceComponentProps());\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) slices.\n\t\t\t\t\t${placeholderInstructions}\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.vue\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cAC6B;AAC7B,QAAM,aAAa,WAAW,KAAK,MAAM,IAAI;AAE7C,MAAI;AAEJ,QAAM,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQhC,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,EACjB,WAAW,qBAAqB;AAC/B,eAAW,YAAA,OAAA,KAAW,qJAIkC,4LAQZ,sDAChB,2CATkB,YAQf,KAAK,MAAM,IACrC,uBAAA;AAAA,EAIN,OAAO;AACN,eAAW,YAAA,OAAA,KAAW,4TAWM,sCAAA,CAAA,IAAvB,uBAAA;AAAA,EAIN;AAEA,QAAM,eAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACA;AACF;AAEO,MAAM,cAA8C,OAC1D,MACA,YACG;AACH,oBACC,MAAM,QAAQ,WAAW;AAAA,IACxB,gBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EAAA,CACxC,CAAC;AAGH,oBACC,MAAM,QAAQ,WAAW;AAAA,IACxB,4BAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACD,4BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EAAA,CACD,CAAC;AAEJ;"}
@@ -95,7 +95,7 @@ const snippetRead = async (data, { helpers }) => {
95
95
  label,
96
96
  language: "vue",
97
97
  code: await format(commonTags.stripIndent`
98
- <PrismicEmbed :field="${dotPath(fieldPath)}" />
98
+ <div v-html="${dotPath(fieldPath)}?.html" />
99
99
  `, helpers)
100
100
  };
101
101
  }
@@ -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\tconst repeat = data.model.config?.repeat ?? false;\n\t\t\tconst allowText = data.model.config?.allowText ?? false;\n\n\t\t\tconst allowVariants = Boolean(data.model.config?.variants);\n\t\t\tconst variant = (path: string) =>\n\t\t\t\tallowVariants ? ` :class=\"${path}.variant\"` : \"\";\n\n\t\t\tconst path = dotPath(fieldPath);\n\n\t\t\tlet codeText;\n\t\t\tif (!repeat && !allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<PrismicLink :field=\"${path}\"${variant(path)}>Link</PrismicLink>\n\t\t\t\t`;\n\t\t\t} else if (!repeat && allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<PrismicLink :field=\"${path}\"${variant(path)} />\n\t\t\t\t`;\n\t\t\t} else if (repeat && !allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<template v-for=\"link in ${path}\" :key=\"link.key\">\n\t\t\t\t\t\t<PrismicLink :field=\"link\"${variant(\"link\")}>Link</PrismicLink>\n\t\t\t\t\t</template>\n\t\t\t\t`;\n\t\t\t} else if (repeat && allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<template v-for=\"link in ${path}\" :key=\"link.key\">\n\t\t\t\t\t\t<PrismicLink :field=\"link\"${variant(\"link\")} />\n\t\t\t\t\t</template>\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tthrow new Error(\"Invalid configuration.\");\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: await format(codeText, helpers),\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 \"Table\": {\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<PrismicTable :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","path"],"mappings":"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"}
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\tconst repeat = data.model.config?.repeat ?? false;\n\t\t\tconst allowText = data.model.config?.allowText ?? false;\n\n\t\t\tconst allowVariants = Boolean(data.model.config?.variants);\n\t\t\tconst variant = (path: string) =>\n\t\t\t\tallowVariants ? ` :class=\"${path}.variant\"` : \"\";\n\n\t\t\tconst path = dotPath(fieldPath);\n\n\t\t\tlet codeText;\n\t\t\tif (!repeat && !allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<PrismicLink :field=\"${path}\"${variant(path)}>Link</PrismicLink>\n\t\t\t\t`;\n\t\t\t} else if (!repeat && allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<PrismicLink :field=\"${path}\"${variant(path)} />\n\t\t\t\t`;\n\t\t\t} else if (repeat && !allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<template v-for=\"link in ${path}\" :key=\"link.key\">\n\t\t\t\t\t\t<PrismicLink :field=\"link\"${variant(\"link\")}>Link</PrismicLink>\n\t\t\t\t\t</template>\n\t\t\t\t`;\n\t\t\t} else if (repeat && allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<template v-for=\"link in ${path}\" :key=\"link.key\">\n\t\t\t\t\t\t<PrismicLink :field=\"link\"${variant(\"link\")} />\n\t\t\t\t\t</template>\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tthrow new Error(\"Invalid configuration.\");\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: await format(codeText, helpers),\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 \"Table\": {\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<PrismicTable :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<div v-html=\"${dotPath(fieldPath)}?.html\" />\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","path"],"mappings":"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"}
@@ -93,7 +93,7 @@ const snippetRead = async (data, { helpers }) => {
93
93
  label,
94
94
  language: "vue",
95
95
  code: await format(stripIndent`
96
- <PrismicEmbed :field="${dotPath(fieldPath)}" />
96
+ <div v-html="${dotPath(fieldPath)}?.html" />
97
97
  `, helpers)
98
98
  };
99
99
  }
@@ -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\tconst repeat = data.model.config?.repeat ?? false;\n\t\t\tconst allowText = data.model.config?.allowText ?? false;\n\n\t\t\tconst allowVariants = Boolean(data.model.config?.variants);\n\t\t\tconst variant = (path: string) =>\n\t\t\t\tallowVariants ? ` :class=\"${path}.variant\"` : \"\";\n\n\t\t\tconst path = dotPath(fieldPath);\n\n\t\t\tlet codeText;\n\t\t\tif (!repeat && !allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<PrismicLink :field=\"${path}\"${variant(path)}>Link</PrismicLink>\n\t\t\t\t`;\n\t\t\t} else if (!repeat && allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<PrismicLink :field=\"${path}\"${variant(path)} />\n\t\t\t\t`;\n\t\t\t} else if (repeat && !allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<template v-for=\"link in ${path}\" :key=\"link.key\">\n\t\t\t\t\t\t<PrismicLink :field=\"link\"${variant(\"link\")}>Link</PrismicLink>\n\t\t\t\t\t</template>\n\t\t\t\t`;\n\t\t\t} else if (repeat && allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<template v-for=\"link in ${path}\" :key=\"link.key\">\n\t\t\t\t\t\t<PrismicLink :field=\"link\"${variant(\"link\")} />\n\t\t\t\t\t</template>\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tthrow new Error(\"Invalid configuration.\");\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: await format(codeText, helpers),\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 \"Table\": {\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<PrismicTable :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":["path"],"mappings":"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"}
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\tconst repeat = data.model.config?.repeat ?? false;\n\t\t\tconst allowText = data.model.config?.allowText ?? false;\n\n\t\t\tconst allowVariants = Boolean(data.model.config?.variants);\n\t\t\tconst variant = (path: string) =>\n\t\t\t\tallowVariants ? ` :class=\"${path}.variant\"` : \"\";\n\n\t\t\tconst path = dotPath(fieldPath);\n\n\t\t\tlet codeText;\n\t\t\tif (!repeat && !allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<PrismicLink :field=\"${path}\"${variant(path)}>Link</PrismicLink>\n\t\t\t\t`;\n\t\t\t} else if (!repeat && allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<PrismicLink :field=\"${path}\"${variant(path)} />\n\t\t\t\t`;\n\t\t\t} else if (repeat && !allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<template v-for=\"link in ${path}\" :key=\"link.key\">\n\t\t\t\t\t\t<PrismicLink :field=\"link\"${variant(\"link\")}>Link</PrismicLink>\n\t\t\t\t\t</template>\n\t\t\t\t`;\n\t\t\t} else if (repeat && allowText) {\n\t\t\t\tcodeText = stripIndent`\n\t\t\t\t\t<template v-for=\"link in ${path}\" :key=\"link.key\">\n\t\t\t\t\t\t<PrismicLink :field=\"link\"${variant(\"link\")} />\n\t\t\t\t\t</template>\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tthrow new Error(\"Invalid configuration.\");\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: await format(codeText, helpers),\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 \"Table\": {\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<PrismicTable :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<div v-html=\"${dotPath(fieldPath)}?.html\" />\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":["path"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-nuxt",
3
- "version": "0.3.92-beta.1",
3
+ "version": "0.3.93-alpha.lh-nuxt-v5.1",
4
4
  "description": "Slice Machine adapter for Nuxt.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -61,7 +61,7 @@
61
61
  "dependencies": {
62
62
  "@prismicio/simulator": "^0.1.4",
63
63
  "@prismicio/types-internal": "3.11.2",
64
- "@slicemachine/plugin-kit": "0.4.90-beta.1",
64
+ "@slicemachine/plugin-kit": "0.4.91-alpha.lh-nuxt-v5.1",
65
65
  "common-tags": "^1.8.2",
66
66
  "fp-ts": "^2.13.1",
67
67
  "io-ts": "^2.2.20",
@@ -104,5 +104,5 @@
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
107
- "stableVersion": "0.3.91"
107
+ "stableVersion": "0.3.92"
108
108
  }
@@ -27,14 +27,15 @@ export const documentationRead: DocumentationReadHook<PluginOptions> = async (
27
27
  if (model.repeatable) {
28
28
  fileContent = stripIndent`
29
29
  <script ${scriptAttributes.join(" ")}>
30
+ import { asImageSrc } from "@prismicio/client";
30
31
  import { components } from "~/slices";
31
32
 
32
- const prismic = usePrismic();
33
33
  const route = useRoute();
34
+ const { client } = usePrismic();
34
35
  const { data: page } = await useAsyncData(\`[${
35
36
  model.id
36
37
  }-uid-\${route.params.uid}]\`, () =>
37
- prismic.client.getByUID("${model.id}", route.params.uid${
38
+ client.getByUID("${model.id}", route.params.uid${
38
39
  isTypeScriptProject ? " as string" : ""
39
40
  })
40
41
  );
@@ -44,26 +45,25 @@ export const documentationRead: DocumentationReadHook<PluginOptions> = async (
44
45
  ogTitle: page.value?.data.meta_title,
45
46
  description: page.value?.data.meta_description,
46
47
  ogDescription: page.value?.data.meta_description,
47
- ogImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),
48
+ ogImage: computed(() => asImageSrc(page.value?.data.meta_image)),
48
49
  });
49
50
  </script>
50
51
 
51
52
  <template>
52
- <SliceZone
53
- wrapper="main"
54
- :slices="page?.data.slices ?? []"
55
- :components="components"
56
- />
53
+ <main>
54
+ <SliceZone :slices="page?.data.slices ?? []" :components="components" />
55
+ </main>
57
56
  </template>
58
57
  `;
59
58
  } else {
60
59
  fileContent = stripIndent`
61
60
  <script ${scriptAttributes.join(" ")}>
61
+ import { asImageSrc } from "@prismicio/client";
62
62
  import { components } from "~/slices";
63
63
 
64
- const prismic = usePrismic();
64
+ const { client } = usePrismic();
65
65
  const { data: page } = await useAsyncData("[${model.id}]", () =>
66
- prismic.client.getSingle("${model.id}")
66
+ client.getSingle("${model.id}")
67
67
  );
68
68
 
69
69
  useSeoMeta({
@@ -71,16 +71,14 @@ export const documentationRead: DocumentationReadHook<PluginOptions> = async (
71
71
  ogTitle: page.value?.data.meta_title,
72
72
  description: page.value?.data.meta_description,
73
73
  ogDescription: page.value?.data.meta_description,
74
- ogImage: computed(() => prismic.asImageSrc(page.value?.data.meta_image)),
74
+ ogImage: computed(() => asImageSrc(page.value?.data.meta_image)),
75
75
  });
76
76
  </script>
77
77
 
78
78
  <template>
79
- <SliceZone
80
- wrapper="main"
81
- :slices="page?.data.slices ?? []"
82
- :components="components"
83
- />
79
+ <main>
80
+ <SliceZone :slices="page?.data.slices ?? []" :components="components" />
81
+ </main>
84
82
  </template>
85
83
  `;
86
84
  }
@@ -51,11 +51,7 @@ const createComponentFile = async ({
51
51
  <script setup lang="ts">
52
52
  import type { Content } from "@prismicio/client";
53
53
 
54
- // The array passed to \`getSliceComponentProps\` is purely optional.
55
- // Consider it as a visual hint for you when templating your slice.
56
- defineProps(getSliceComponentProps<Content.${pascalName}Slice>(
57
- ["slice", "index", "slices", "context"]
58
- ));
54
+ defineProps(getSliceComponentProps<Content.${pascalName}Slice>());
59
55
  </script>
60
56
 
61
57
  <template>
@@ -71,9 +67,7 @@ const createComponentFile = async ({
71
67
  } else {
72
68
  contents = stripIndent`
73
69
  <script setup>
74
- // The array passed to \`getSliceComponentProps\` is purely optional.
75
- // Consider it as a visual hint for you when templating your slice.
76
- defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
70
+ defineProps(getSliceComponentProps());
77
71
  </script>
78
72
 
79
73
  <template>
@@ -131,7 +131,7 @@ export const snippetRead: SnippetReadHook<PluginOptions> = async (
131
131
  language: "vue",
132
132
  code: await format(
133
133
  stripIndent`
134
- <PrismicEmbed :field="${dotPath(fieldPath)}" />
134
+ <div v-html="${dotPath(fieldPath)}?.html" />
135
135
  `,
136
136
  helpers,
137
137
  ),