@slicemachine/adapter-sveltekit 0.3.78-beta.12 → 0.3.78-beta.14

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.
Files changed (70) hide show
  1. package/dist/AlternateGrid/javascript.4.svelte +227 -0
  2. package/dist/AlternateGrid/javascript.svelte +6 -5
  3. package/dist/AlternateGrid/typescript.4.svelte +224 -0
  4. package/dist/AlternateGrid/typescript.svelte +9 -4
  5. package/dist/CallToAction/javascript.4.svelte +127 -0
  6. package/dist/CallToAction/javascript.svelte +6 -5
  7. package/dist/CallToAction/typescript.4.svelte +124 -0
  8. package/dist/CallToAction/typescript.svelte +4 -2
  9. package/dist/CustomerLogos/javascript.4.svelte +124 -0
  10. package/dist/CustomerLogos/javascript.svelte +6 -5
  11. package/dist/CustomerLogos/typescript.4.svelte +121 -0
  12. package/dist/CustomerLogos/typescript.svelte +4 -2
  13. package/dist/Hero/javascript.4.svelte +190 -0
  14. package/dist/Hero/javascript.svelte +5 -4
  15. package/dist/Hero/typescript.4.svelte +187 -0
  16. package/dist/Hero/typescript.svelte +4 -2
  17. package/dist/hooks/documentation-read.cjs +14 -51
  18. package/dist/hooks/documentation-read.cjs.map +1 -1
  19. package/dist/hooks/documentation-read.js +14 -51
  20. package/dist/hooks/documentation-read.js.map +1 -1
  21. package/dist/hooks/documentation-read.templates.cjs +114 -0
  22. package/dist/hooks/documentation-read.templates.cjs.map +1 -0
  23. package/dist/hooks/documentation-read.templates.d.ts +9 -0
  24. package/dist/hooks/documentation-read.templates.js +114 -0
  25. package/dist/hooks/documentation-read.templates.js.map +1 -0
  26. package/dist/hooks/project-init.cjs +44 -143
  27. package/dist/hooks/project-init.cjs.map +1 -1
  28. package/dist/hooks/project-init.js +44 -143
  29. package/dist/hooks/project-init.js.map +1 -1
  30. package/dist/hooks/project-init.templates.cjs +181 -0
  31. package/dist/hooks/project-init.templates.cjs.map +1 -0
  32. package/dist/hooks/project-init.templates.d.ts +12 -0
  33. package/dist/hooks/project-init.templates.js +181 -0
  34. package/dist/hooks/project-init.templates.js.map +1 -0
  35. package/dist/hooks/slice-create.cjs +5 -52
  36. package/dist/hooks/slice-create.cjs.map +1 -1
  37. package/dist/hooks/slice-create.js +5 -52
  38. package/dist/hooks/slice-create.js.map +1 -1
  39. package/dist/hooks/slice-create.templates.cjs +61 -0
  40. package/dist/hooks/slice-create.templates.cjs.map +1 -0
  41. package/dist/hooks/slice-create.templates.d.ts +6 -0
  42. package/dist/hooks/slice-create.templates.js +61 -0
  43. package/dist/hooks/slice-create.templates.js.map +1 -0
  44. package/dist/lib/getSvelteMajor.cjs +38 -0
  45. package/dist/lib/getSvelteMajor.cjs.map +1 -0
  46. package/dist/lib/getSvelteMajor.d.ts +1 -0
  47. package/dist/lib/getSvelteMajor.js +16 -0
  48. package/dist/lib/getSvelteMajor.js.map +1 -0
  49. package/dist/lib/requireResolve.cjs +16 -0
  50. package/dist/lib/requireResolve.cjs.map +1 -0
  51. package/dist/lib/requireResolve.d.ts +10 -0
  52. package/dist/lib/requireResolve.js +16 -0
  53. package/dist/lib/requireResolve.js.map +1 -0
  54. package/dist/plugin.cjs +4 -2
  55. package/dist/plugin.cjs.map +1 -1
  56. package/dist/plugin.js +4 -2
  57. package/dist/plugin.js.map +1 -1
  58. package/dist/simulator/SliceSimulator.svelte +3 -2
  59. package/dist/simulator/SliceSimulator.svelte.d.ts +7 -19
  60. package/package.json +7 -6
  61. package/src/hooks/documentation-read.templates.ts +170 -0
  62. package/src/hooks/documentation-read.ts +21 -59
  63. package/src/hooks/project-init.templates.ts +208 -0
  64. package/src/hooks/project-init.ts +57 -147
  65. package/src/hooks/slice-create.templates.ts +103 -0
  66. package/src/hooks/slice-create.ts +7 -66
  67. package/src/lib/getSvelteMajor.ts +23 -0
  68. package/src/lib/requireResolve.ts +30 -0
  69. package/src/plugin.ts +5 -2
  70. package/src/simulator/SliceSimulator.svelte +3 -2
@@ -0,0 +1,187 @@
1
+ <script lang="ts">
2
+ import {
3
+ PrismicImage,
4
+ PrismicRichText,
5
+ PrismicLink,
6
+ } from "@prismicio/svelte";
7
+ import { type Content, isFilled } from "@prismicio/client";
8
+
9
+ export let slice: Content.PascalNameToReplaceSlice;
10
+ </script>
11
+
12
+ <section
13
+ data-slice-type={slice.slice_type}
14
+ data-slice-variation={slice.variation}
15
+ class="es-bounded es-fullpage-hero"
16
+ >
17
+ <div
18
+ class={`
19
+ es-fullpage-hero__content
20
+ ${
21
+ slice.variation === "imageRight"
22
+ ? "es-fullpage-hero__image--right"
23
+ : "es-fullpage-hero__image--left"
24
+ }
25
+ `}
26
+ >
27
+ <div>
28
+ {#if isFilled.image(slice.primary.image)}
29
+ <PrismicImage
30
+ field={slice.primary.image}
31
+ class="es-fullpage-hero__image"
32
+ />
33
+ {/if}
34
+ </div>
35
+ <div class="es-fullpage-hero__content-right">
36
+ <div class="es-fullpage-hero__content__intro">
37
+ {#if isFilled.keyText(slice.primary.eyebrowHeadline)}
38
+ <p class="es-fullpage-hero__content__intro__eyebrow">
39
+ {slice.primary.eyebrowHeadline}
40
+ </p>
41
+ {/if}
42
+ {#if isFilled.richText(slice.primary.title)}
43
+ <div class="es-fullpage-hero__content__intro__headline">
44
+ <PrismicRichText field={slice.primary.title} />
45
+ </div>
46
+ {/if}
47
+ {#if isFilled.richText(slice.primary.description)}
48
+ <div class="es-fullpage-hero__content__intro__description">
49
+ <PrismicRichText field={slice.primary.description} />
50
+ </div>
51
+ {/if}
52
+ <PrismicLink
53
+ field={slice.primary.callToActionLink}
54
+ class="es-call-to-action__link"
55
+ />
56
+ </div>
57
+ </div>
58
+ </div>
59
+
60
+ <style>
61
+ .es-bounded {
62
+ margin: 0px;
63
+ min-width: 0px;
64
+ position: relative;
65
+ }
66
+
67
+ .es-fullpage-hero {
68
+ font-family: system-ui, sans-serif;
69
+ background-color: #fff;
70
+ color: #333;
71
+ }
72
+
73
+ .es-fullpage-hero__image {
74
+ max-width: 100%;
75
+ height: auto;
76
+ align-self: center;
77
+ }
78
+
79
+ .es-fullpage-hero__image--left > div:first-child {
80
+ order: 1;
81
+ }
82
+
83
+ .es-fullpage-hero__image--left > div:nth-child(2) {
84
+ order: 2;
85
+ }
86
+
87
+ .es-fullpage-hero__image--right > div:first-child {
88
+ order: 2;
89
+ }
90
+
91
+ .es-fullpage-hero__image--right > div:nth-child(2) {
92
+ order: 1;
93
+ }
94
+
95
+ .es-fullpage-hero__content {
96
+ display: flex;
97
+ flex-direction: column;
98
+ gap: 2rem;
99
+ }
100
+
101
+ .es-fullpage-hero__content-right {
102
+ display: flex;
103
+ flex-direction: column;
104
+ justify-content: space-around;
105
+ padding: 1.5rem;
106
+ }
107
+
108
+ @media (min-width: 1080px) {
109
+ .es-fullpage-hero__content {
110
+ flex-direction: row;
111
+ }
112
+
113
+ .es-fullpage-hero__content > div {
114
+ width: 50%;
115
+ }
116
+ }
117
+
118
+ .es-fullpage-hero__content__intro {
119
+ display: grid;
120
+ gap: 1rem;
121
+ }
122
+
123
+ .es-fullpage-hero__content__intro__eyebrow {
124
+ color: #47c1af;
125
+ font-size: 1.15rem;
126
+ font-weight: 500;
127
+ margin: 0;
128
+ }
129
+
130
+ .es-fullpage-hero__content__intro__headline {
131
+ font-size: 1.625rem;
132
+ font-weight: 700;
133
+ }
134
+
135
+ .es-fullpage-hero__content__intro__headline * {
136
+ margin: 0;
137
+ }
138
+
139
+ @media (min-width: 640px) {
140
+ .es-fullpage-hero__content__intro__headline {
141
+ font-size: 2rem;
142
+ }
143
+ }
144
+
145
+ @media (min-width: 1024px) {
146
+ .es-fullpage-hero__content__intro__headline {
147
+ font-size: 2.5rem;
148
+ }
149
+ }
150
+
151
+ @media (min-width: 1200px) {
152
+ .es-fullpage-hero__content__intro__headline {
153
+ font-size: 2.75rem;
154
+ }
155
+ }
156
+
157
+ .es-fullpage-hero__content__intro__description {
158
+ font-size: 1.15rem;
159
+ max-width: 38rem;
160
+ }
161
+
162
+ .es-fullpage-hero__content__intro__description > p {
163
+ margin: 0;
164
+ }
165
+
166
+ @media (min-width: 1200px) {
167
+ .es-fullpage-hero__content__intro__description {
168
+ font-size: 1.4rem;
169
+ }
170
+ }
171
+
172
+ .es-call-to-action__link {
173
+ justify-self: flex-start;
174
+ border-radius: 0.25rem;
175
+ font-size: 0.875rem;
176
+ line-height: 1.3;
177
+ padding: 1rem 2.625rem;
178
+ transition: background-color 100ms linear;
179
+ background-color: #16745f;
180
+ color: #fff;
181
+ }
182
+
183
+ .es-call-to-action__link:hover {
184
+ background-color: #0d5e4c;
185
+ }
186
+ </style>
187
+ </section>
@@ -1,12 +1,14 @@
1
1
  <script lang="ts">
2
+ import { type Content, isFilled } from "@prismicio/client";
2
3
  import {
3
4
  PrismicImage,
4
5
  PrismicRichText,
5
6
  PrismicLink,
7
+ type SliceComponentProps,
6
8
  } from "@prismicio/svelte";
7
- import { type Content, isFilled } from "@prismicio/client";
8
9
 
9
- export let slice: Content.PascalNameToReplaceSlice;
10
+ const { slice }: SliceComponentProps<Content.PascalNameToReplaceSlice> =
11
+ $props();
10
12
  </script>
11
13
 
12
14
  <section
@@ -2,10 +2,9 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const commonTags = require("common-tags");
4
4
  const getJSFileExtension = require("../lib/getJSFileExtension.cjs");
5
- var __freeze = Object.freeze;
6
- var __defProp = Object.defineProperty;
7
- var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
8
- var _a;
5
+ const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
6
+ const documentationRead_templates = require("./documentation-read.templates.cjs");
7
+ const getSvelteMajor = require("../lib/getSvelteMajor.cjs");
9
8
  const nestRouteFilePath = (filePath, nesting) => {
10
9
  return [
11
10
  ...filePath.split("/").slice(0, 2),
@@ -17,58 +16,22 @@ const documentationRead = async (data, { options, helpers }) => {
17
16
  if (data.kind === "PageSnippet") {
18
17
  const { model } = data.data;
19
18
  const pageDataExtension = await getJSFileExtension.getJSFileExtension({ helpers, options });
20
- const routePath = `src/routes/${model.repeatable ? "[uid]" : model.id}`;
19
+ const pageDataLanguage = pageDataExtension === "ts" ? "typescript" : "javascript";
20
+ const typescript = await checkIsTypeScriptProject.checkIsTypeScriptProject({ options, helpers });
21
+ const routePath = `src/routes/[[preview=preview]]/${model.repeatable ? "[uid]" : model.id}`;
21
22
  const dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;
22
23
  const componentFilePath = `${routePath}/+page.svelte`;
23
- let dataFileContent;
24
- if (model.repeatable) {
25
- dataFileContent = commonTags.source`
26
- import { createClient } from "$lib/prismicio";
27
-
28
- export async function load({ params, fetch, cookies }) {
29
- const client = createClient({ fetch, cookies });
30
-
31
- const page = await client.getByUID("${model.id}", params.uid);
32
-
33
- return {
34
- page,
35
- };
36
- }
37
-
38
- export async function entries() {
39
- const client = createClient();
40
-
41
- const pages = await client.getAllByType("${model.id}");
42
-
43
- return pages.map((page) => {
44
- return { uid: page.uid };
45
- });
46
- }
47
- `;
48
- } else {
49
- dataFileContent = commonTags.source`
50
- import { createClient } from "$lib/prismicio";
51
-
52
- export async function load({ params, fetch, cookies }) {
53
- const client = createClient({ fetch, cookies });
54
-
55
- const page = await client.getSingle("${model.id}");
56
-
57
- return {
58
- page,
59
- };
60
- }
61
-
62
- export async function entries() {
63
- return [{}]
64
- }
65
- `;
66
- }
67
- let componentFileContent = commonTags.source(_a || (_a = __template(['\n <script>\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n\n export let data;\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
24
+ let dataFileContent = documentationRead_templates.dataFileTemplate({ model, typescript });
68
25
  if (options.format) {
69
26
  dataFileContent = await helpers.format(dataFileContent, helpers.joinPathFromRoot(dataFilePath), {
70
27
  includeNewlineAtEnd: false
71
28
  });
29
+ }
30
+ let componentFileContent = documentationRead_templates.componentFileTemplate({
31
+ typescript,
32
+ version: await getSvelteMajor.getSvelteMajor()
33
+ });
34
+ if (options.format) {
72
35
  componentFileContent = await helpers.format(componentFileContent, helpers.joinPathFromRoot(componentFilePath), {
73
36
  prettier: {
74
37
  plugins: ["prettier-plugin-svelte"],
@@ -89,7 +52,7 @@ const documentationRead = async (data, { options, helpers }) => {
89
52
 
90
53
  Paste in this code:
91
54
 
92
- ${`~~~${pageDataExtension} [${dataFilePath}]
55
+ ${`~~~${pageDataLanguage} [${dataFilePath}]
93
56
  ${dataFileContent}
94
57
  ~~~`}
95
58
 
@@ -1 +1 @@
1
- {"version":3,"file":"documentation-read.cjs","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst nestRouteFilePath = (filePath: string, nesting: string): string => {\n\treturn [\n\t\t...filePath.split(\"/\").slice(0, 2),\n\t\tnesting,\n\t\t...filePath.split(\"/\").slice(2),\n\t].join(\"/\");\n};\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\n\t\tconst pageDataExtension = await getJSFileExtension({ helpers, options });\n\n\t\tconst routePath = `src/routes/${model.repeatable ? \"[uid]\" : model.id}`;\n\t\tconst dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;\n\t\tconst componentFilePath = `${routePath}/+page.svelte`;\n\n\t\tlet dataFileContent: string;\n\t\tif (model.repeatable) {\n\t\t\tdataFileContent = source`\n\t\t\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t\t\texport async function load({ params, fetch, cookies }) {\n\t\t\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\texport async function entries() {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\t\t\treturn pages.map((page) => {\n\t\t\t\t\t\treturn { uid: page.uid };\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tdataFileContent = source`\n\t\t\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t\t\texport async function load({ params, fetch, cookies }) {\n\t\t\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\texport async function entries() {\n\t\t\t\t\treturn [{}]\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\n\t\tlet componentFileContent = source`\n\t\t\t<script>\n\t\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\t\timport { components } from \"$lib/slices\";\n\n\t\t\t\texport let data;\n\t\t\t</script>\n\n\t\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t\t`;\n\n\t\tif (options.format) {\n\t\t\tdataFileContent = await helpers.format(\n\t\t\t\tdataFileContent,\n\t\t\t\thelpers.joinPathFromRoot(dataFilePath),\n\t\t\t\t{\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\tcomponentFileContent = await helpers.format(\n\t\t\t\tcomponentFileContent,\n\t\t\t\thelpers.joinPathFromRoot(componentFilePath),\n\t\t\t\t{\n\t\t\t\t\tprettier: {\n\t\t\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\t\t\tparser: \"svelte\",\n\t\t\t\t\t},\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst nestedDataFilePath = nestRouteFilePath(dataFilePath, \"marketing\");\n\t\tconst nestedComponentFilePath = nestRouteFilePath(\n\t\t\tcomponentFilePath,\n\t\t\t\"marketing\",\n\t\t);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Default\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page data fetcher\n\n\t\t\t\t\tAdd a new route by creating a \\`${dataFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedDataFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~${pageDataExtension} [${dataFilePath}]\\n${dataFileContent}\\n~~~`}\n\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tIn the route's directory, create a \\`${componentFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedComponentFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~svelte [${componentFilePath}]\\n${componentFileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":["getJSFileExtension","source"],"mappings":";;;;;;;AAAA,IAAA;AAQA,MAAM,oBAAoB,CAAC,UAAkB,YAA2B;AAChE,SAAA;AAAA,IACN,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC;AAAA,IACjC;AAAA,IACA,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,CAAC;AAAA,EAAA,EAC7B,KAAK,GAAG;AACX;AAEO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACC,MAAA,KAAK,SAAS,eAAe;AAC1B,UAAA,EAAE,MAAK,IAAK,KAAK;AAEvB,UAAM,oBAAoB,MAAMA,mBAAA,mBAAmB,EAAE,SAAS,QAAS,CAAA;AAEvE,UAAM,YAAY,cAAc,MAAM,aAAa,UAAU,MAAM,EAAE;AACrE,UAAM,eAAe,GAAG,SAAS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,gHAAgH,uBAAuB;AAAA;AAAA;AAAA;AAAA,OAI7L,cAAc,iBAAiB;AAAA,EAAM,oBAAoB;AAAA,IAAO;AAAA;AAAA;AAAA;AAAA,MAInE;AAAA,IAAA;AAAA,EAEH;AAEA,SAAO;AACR;;"}
1
+ {"version":3,"file":"documentation-read.cjs","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport type { PluginOptions } from \"../types\";\nimport {\n\tcomponentFileTemplate,\n\tdataFileTemplate,\n} from \"./documentation-read.templates\";\nimport { getSvelteMajor } from \"../lib/getSvelteMajor\";\n\nconst nestRouteFilePath = (filePath: string, nesting: string): string => {\n\treturn [\n\t\t...filePath.split(\"/\").slice(0, 2),\n\t\tnesting,\n\t\t...filePath.split(\"/\").slice(2),\n\t].join(\"/\");\n};\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\n\t\tconst pageDataExtension = await getJSFileExtension({ helpers, options });\n\t\tconst pageDataLanguage =\n\t\t\tpageDataExtension === \"ts\" ? \"typescript\" : \"javascript\";\n\t\tconst typescript = await checkIsTypeScriptProject({ options, helpers });\n\n\t\tconst routePath = `src/routes/[[preview=preview]]/${\n\t\t\tmodel.repeatable ? \"[uid]\" : model.id\n\t\t}`;\n\t\tconst dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;\n\t\tconst componentFilePath = `${routePath}/+page.svelte`;\n\n\t\tlet dataFileContent = dataFileTemplate({ model, typescript });\n\t\tif (options.format) {\n\t\t\tdataFileContent = await helpers.format(\n\t\t\t\tdataFileContent,\n\t\t\t\thelpers.joinPathFromRoot(dataFilePath),\n\t\t\t\t{\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tlet componentFileContent = componentFileTemplate({\n\t\t\ttypescript,\n\t\t\tversion: await getSvelteMajor(),\n\t\t});\n\t\tif (options.format) {\n\t\t\tcomponentFileContent = await helpers.format(\n\t\t\t\tcomponentFileContent,\n\t\t\t\thelpers.joinPathFromRoot(componentFilePath),\n\t\t\t\t{\n\t\t\t\t\tprettier: {\n\t\t\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\t\t\tparser: \"svelte\",\n\t\t\t\t\t},\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst nestedDataFilePath = nestRouteFilePath(dataFilePath, \"marketing\");\n\t\tconst nestedComponentFilePath = nestRouteFilePath(\n\t\t\tcomponentFilePath,\n\t\t\t\"marketing\",\n\t\t);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Default\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page data fetcher\n\n\t\t\t\t\tAdd a new route by creating a \\`${dataFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedDataFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~${pageDataLanguage} [${dataFilePath}]\\n${dataFileContent}\\n~~~`}\n\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tIn the route's directory, create a \\`${componentFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedComponentFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~svelte [${componentFilePath}]\\n${componentFileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":["getJSFileExtension","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AAA,IAEH;AAEM,UAAA,qBAAqB,kBAAkB,cAAc,WAAW;AAChE,UAAA,0BAA0B,kBAC/B,mBACA,WAAW;AAGL,WAAA;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAASC,WAAAA;AAAAA,sBACS,MAAM,KAAK;AAAA;AAAA,uCAEM,YAAY,gHAAgH,kBAAkB;AAAA;AAAA;AAAA;AAAA,OAI9K,MAAM,gBAAgB,KAAK,YAAY;AAAA,EAAM,eAAe;AAAA,IAAO;AAAA;AAAA,sBAEpD,MAAM,KAAK;AAAA;AAAA,4CAEW,iBAAiB,gHAAgH,uBAAuB;AAAA;AAAA;AAAA;AAAA,OAI7L,cAAc,iBAAiB;AAAA,EAAM,oBAAoB;AAAA,IAAO;AAAA;AAAA;AAAA;AAAA,MAInE;AAAA,IAAA;AAAA,EAEH;AAEA,SAAO;AACR;;"}
@@ -1,9 +1,8 @@
1
1
  import { source } from "common-tags";
2
2
  import { getJSFileExtension } from "../lib/getJSFileExtension.js";
3
- var __freeze = Object.freeze;
4
- var __defProp = Object.defineProperty;
5
- var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
6
- var _a;
3
+ import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
4
+ import { dataFileTemplate, componentFileTemplate } from "./documentation-read.templates.js";
5
+ import { getSvelteMajor } from "../lib/getSvelteMajor.js";
7
6
  const nestRouteFilePath = (filePath, nesting) => {
8
7
  return [
9
8
  ...filePath.split("/").slice(0, 2),
@@ -15,58 +14,22 @@ const documentationRead = async (data, { options, helpers }) => {
15
14
  if (data.kind === "PageSnippet") {
16
15
  const { model } = data.data;
17
16
  const pageDataExtension = await getJSFileExtension({ helpers, options });
18
- const routePath = `src/routes/${model.repeatable ? "[uid]" : model.id}`;
17
+ const pageDataLanguage = pageDataExtension === "ts" ? "typescript" : "javascript";
18
+ const typescript = await checkIsTypeScriptProject({ options, helpers });
19
+ const routePath = `src/routes/[[preview=preview]]/${model.repeatable ? "[uid]" : model.id}`;
19
20
  const dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;
20
21
  const componentFilePath = `${routePath}/+page.svelte`;
21
- let dataFileContent;
22
- if (model.repeatable) {
23
- dataFileContent = source`
24
- import { createClient } from "$lib/prismicio";
25
-
26
- export async function load({ params, fetch, cookies }) {
27
- const client = createClient({ fetch, cookies });
28
-
29
- const page = await client.getByUID("${model.id}", params.uid);
30
-
31
- return {
32
- page,
33
- };
34
- }
35
-
36
- export async function entries() {
37
- const client = createClient();
38
-
39
- const pages = await client.getAllByType("${model.id}");
40
-
41
- return pages.map((page) => {
42
- return { uid: page.uid };
43
- });
44
- }
45
- `;
46
- } else {
47
- dataFileContent = source`
48
- import { createClient } from "$lib/prismicio";
49
-
50
- export async function load({ params, fetch, cookies }) {
51
- const client = createClient({ fetch, cookies });
52
-
53
- const page = await client.getSingle("${model.id}");
54
-
55
- return {
56
- page,
57
- };
58
- }
59
-
60
- export async function entries() {
61
- return [{}]
62
- }
63
- `;
64
- }
65
- let componentFileContent = source(_a || (_a = __template(['\n <script>\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n\n export let data;\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
22
+ let dataFileContent = dataFileTemplate({ model, typescript });
66
23
  if (options.format) {
67
24
  dataFileContent = await helpers.format(dataFileContent, helpers.joinPathFromRoot(dataFilePath), {
68
25
  includeNewlineAtEnd: false
69
26
  });
27
+ }
28
+ let componentFileContent = componentFileTemplate({
29
+ typescript,
30
+ version: await getSvelteMajor()
31
+ });
32
+ if (options.format) {
70
33
  componentFileContent = await helpers.format(componentFileContent, helpers.joinPathFromRoot(componentFilePath), {
71
34
  prettier: {
72
35
  plugins: ["prettier-plugin-svelte"],
@@ -87,7 +50,7 @@ const documentationRead = async (data, { options, helpers }) => {
87
50
 
88
51
  Paste in this code:
89
52
 
90
- ${`~~~${pageDataExtension} [${dataFilePath}]
53
+ ${`~~~${pageDataLanguage} [${dataFilePath}]
91
54
  ${dataFileContent}
92
55
  ~~~`}
93
56
 
@@ -1 +1 @@
1
- {"version":3,"file":"documentation-read.js","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst nestRouteFilePath = (filePath: string, nesting: string): string => {\n\treturn [\n\t\t...filePath.split(\"/\").slice(0, 2),\n\t\tnesting,\n\t\t...filePath.split(\"/\").slice(2),\n\t].join(\"/\");\n};\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\n\t\tconst pageDataExtension = await getJSFileExtension({ helpers, options });\n\n\t\tconst routePath = `src/routes/${model.repeatable ? \"[uid]\" : model.id}`;\n\t\tconst dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;\n\t\tconst componentFilePath = `${routePath}/+page.svelte`;\n\n\t\tlet dataFileContent: string;\n\t\tif (model.repeatable) {\n\t\t\tdataFileContent = source`\n\t\t\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t\t\texport async function load({ params, fetch, cookies }) {\n\t\t\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\texport async function entries() {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\t\t\treturn pages.map((page) => {\n\t\t\t\t\t\treturn { uid: page.uid };\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tdataFileContent = source`\n\t\t\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t\t\texport async function load({ params, fetch, cookies }) {\n\t\t\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\texport async function entries() {\n\t\t\t\t\treturn [{}]\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\n\t\tlet componentFileContent = source`\n\t\t\t<script>\n\t\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\t\timport { components } from \"$lib/slices\";\n\n\t\t\t\texport let data;\n\t\t\t</script>\n\n\t\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t\t`;\n\n\t\tif (options.format) {\n\t\t\tdataFileContent = await helpers.format(\n\t\t\t\tdataFileContent,\n\t\t\t\thelpers.joinPathFromRoot(dataFilePath),\n\t\t\t\t{\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\tcomponentFileContent = await helpers.format(\n\t\t\t\tcomponentFileContent,\n\t\t\t\thelpers.joinPathFromRoot(componentFilePath),\n\t\t\t\t{\n\t\t\t\t\tprettier: {\n\t\t\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\t\t\tparser: \"svelte\",\n\t\t\t\t\t},\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst nestedDataFilePath = nestRouteFilePath(dataFilePath, \"marketing\");\n\t\tconst nestedComponentFilePath = nestRouteFilePath(\n\t\t\tcomponentFilePath,\n\t\t\t\"marketing\",\n\t\t);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Default\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page data fetcher\n\n\t\t\t\t\tAdd a new route by creating a \\`${dataFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedDataFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~${pageDataExtension} [${dataFilePath}]\\n${dataFileContent}\\n~~~`}\n\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tIn the route's directory, create a \\`${componentFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedComponentFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~svelte [${componentFilePath}]\\n${componentFileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) 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;AAQA,MAAM,oBAAoB,CAAC,UAAkB,YAA2B;AAChE,SAAA;AAAA,IACN,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC;AAAA,IACjC;AAAA,IACA,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,CAAC;AAAA,EAAA,EAC7B,KAAK,GAAG;AACX;AAEO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACC,MAAA,KAAK,SAAS,eAAe;AAC1B,UAAA,EAAE,MAAK,IAAK,KAAK;AAEvB,UAAM,oBAAoB,MAAM,mBAAmB,EAAE,SAAS,QAAS,CAAA;AAEvE,UAAM,YAAY,cAAc,MAAM,aAAa,UAAU,MAAM,EAAE;AACrE,UAAM,eAAe,GAAG,SAAS,iBAAiB,iBAAiB;AAC7D,UAAA,oBAAoB,GAAG,SAAS;AAElC,QAAA;AACJ,QAAI,MAAM,YAAY;AACH,wBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2CAMsB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gDAUH,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,OAO/C;AACY,wBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4CAMuB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWlD;AAEA,QAAI,uBAAuB,OAAM,OAAA,KAAA,WAAA,CAAA,+NAAA,CAAA,EAAA;AAYjC,QAAI,QAAQ,QAAQ;AACnB,wBAAkB,MAAM,QAAQ,OAC/B,iBACA,QAAQ,iBAAiB,YAAY,GACrC;AAAA,QACC,qBAAqB;AAAA,MAAA,CACrB;AAEF,6BAAuB,MAAM,QAAQ,OACpC,sBACA,QAAQ,iBAAiB,iBAAiB,GAC1C;AAAA,QACC,UAAU;AAAA,UACT,SAAS,CAAC,wBAAwB;AAAA,UAClC,QAAQ;AAAA,QACR;AAAA,QACD,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEH;AAEM,UAAA,qBAAqB,kBAAkB,cAAc,WAAW;AAChE,UAAA,0BAA0B,kBAC/B,mBACA,WAAW;AAGL,WAAA;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAAS;AAAA,sBACS,MAAM,KAAK;AAAA;AAAA,uCAEM,YAAY,gHAAgH,kBAAkB;AAAA;AAAA;AAAA;AAAA,OAI9K,MAAM,iBAAiB,KAAK,YAAY;AAAA,EAAM,eAAe;AAAA,IAAO;AAAA;AAAA,sBAErD,MAAM,KAAK;AAAA;AAAA,4CAEW,iBAAiB,gHAAgH,uBAAuB;AAAA;AAAA;AAAA;AAAA,OAI7L,cAAc,iBAAiB;AAAA,EAAM,oBAAoB;AAAA,IAAO;AAAA;AAAA;AAAA;AAAA,MAInE;AAAA,IAAA;AAAA,EAEH;AAEA,SAAO;AACR;"}
1
+ {"version":3,"file":"documentation-read.js","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport type { PluginOptions } from \"../types\";\nimport {\n\tcomponentFileTemplate,\n\tdataFileTemplate,\n} from \"./documentation-read.templates\";\nimport { getSvelteMajor } from \"../lib/getSvelteMajor\";\n\nconst nestRouteFilePath = (filePath: string, nesting: string): string => {\n\treturn [\n\t\t...filePath.split(\"/\").slice(0, 2),\n\t\tnesting,\n\t\t...filePath.split(\"/\").slice(2),\n\t].join(\"/\");\n};\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\n\t\tconst pageDataExtension = await getJSFileExtension({ helpers, options });\n\t\tconst pageDataLanguage =\n\t\t\tpageDataExtension === \"ts\" ? \"typescript\" : \"javascript\";\n\t\tconst typescript = await checkIsTypeScriptProject({ options, helpers });\n\n\t\tconst routePath = `src/routes/[[preview=preview]]/${\n\t\t\tmodel.repeatable ? \"[uid]\" : model.id\n\t\t}`;\n\t\tconst dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;\n\t\tconst componentFilePath = `${routePath}/+page.svelte`;\n\n\t\tlet dataFileContent = dataFileTemplate({ model, typescript });\n\t\tif (options.format) {\n\t\t\tdataFileContent = await helpers.format(\n\t\t\t\tdataFileContent,\n\t\t\t\thelpers.joinPathFromRoot(dataFilePath),\n\t\t\t\t{\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tlet componentFileContent = componentFileTemplate({\n\t\t\ttypescript,\n\t\t\tversion: await getSvelteMajor(),\n\t\t});\n\t\tif (options.format) {\n\t\t\tcomponentFileContent = await helpers.format(\n\t\t\t\tcomponentFileContent,\n\t\t\t\thelpers.joinPathFromRoot(componentFilePath),\n\t\t\t\t{\n\t\t\t\t\tprettier: {\n\t\t\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\t\t\tparser: \"svelte\",\n\t\t\t\t\t},\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst nestedDataFilePath = nestRouteFilePath(dataFilePath, \"marketing\");\n\t\tconst nestedComponentFilePath = nestRouteFilePath(\n\t\t\tcomponentFilePath,\n\t\t\t\"marketing\",\n\t\t);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Default\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page data fetcher\n\n\t\t\t\t\tAdd a new route by creating a \\`${dataFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedDataFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~${pageDataLanguage} [${dataFilePath}]\\n${dataFileContent}\\n~~~`}\n\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tIn the route's directory, create a \\`${componentFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`${nestedComponentFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~svelte [${componentFilePath}]\\n${componentFileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":[],"mappings":";;;;;AAcA,MAAM,oBAAoB,CAAC,UAAkB,YAA2B;AAChE,SAAA;AAAA,IACN,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC;AAAA,IACjC;AAAA,IACA,GAAG,SAAS,MAAM,GAAG,EAAE,MAAM,CAAC;AAAA,EAAA,EAC7B,KAAK,GAAG;AACX;AAEO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACC,MAAA,KAAK,SAAS,eAAe;AAC1B,UAAA,EAAE,MAAK,IAA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AA,EAAM,oBAAoB;AAAA,IAAO;AAAA;AAAA;AAAA;AAAA,MAInE;AAAA,IAAA;AAAA,EAEH;AAEA,SAAO;AACR;"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const commonTags = require("common-tags");
4
+ var __freeze = Object.freeze;
5
+ var __defProp = Object.defineProperty;
6
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
7
+ var _a, _b, _c, _d;
8
+ function dataFileTemplate(args) {
9
+ const { model, typescript } = args;
10
+ const repeatableTS = commonTags.source`
11
+ import { createClient } from "$lib/prismicio";
12
+ import type { PageServerLoad, EntryGenerator } from './$types';
13
+
14
+ export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
15
+ const client = createClient({ fetch, cookies });
16
+
17
+ const page = await client.getByUID("${model.id}", params.uid);
18
+
19
+ return {
20
+ page,
21
+ };
22
+ }
23
+
24
+ export const entries: EntryGenerator = async () => {
25
+ const client = createClient();
26
+
27
+ const pages = await client.getAllByType("${model.id}");
28
+
29
+ return pages.map((page) => {
30
+ return { uid: page.uid };
31
+ });
32
+ }
33
+ `;
34
+ const nonrepeatableTS = commonTags.source`
35
+ import { createClient } from "$lib/prismicio";
36
+ import type { PageServerLoad, EntryGenerator } from './$types';
37
+
38
+ export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
39
+ const client = createClient({ fetch, cookies });
40
+
41
+ const page = await client.getSingle("${model.id}");
42
+
43
+ return {
44
+ page,
45
+ };
46
+ }
47
+
48
+ export const entries: EntryGenerator = async () => {
49
+ return [{}]
50
+ }
51
+ `;
52
+ const repeatableJS = commonTags.source`
53
+ import { createClient } from "$lib/prismicio";
54
+
55
+ /* @type {import("./$types").PageServerLoad} */
56
+ export async function load({ params, fetch, cookies }) {
57
+ const client = createClient({ fetch, cookies });
58
+
59
+ const page = await client.getByUID("${model.id}", params.uid);
60
+
61
+ return {
62
+ page,
63
+ };
64
+ }
65
+
66
+ /* @type {import("./$types").EntryGenerator} */
67
+ export async function entries() {
68
+ const client = createClient();
69
+
70
+ const pages = await client.getAllByType("${model.id}");
71
+
72
+ return pages.map((page) => {
73
+ return { uid: page.uid };
74
+ });
75
+ }
76
+ `;
77
+ const nonrepeatableJS = commonTags.source`
78
+ import { createClient } from "$lib/prismicio";
79
+
80
+ /* @type {import("./$types").PageServerLoad} */
81
+ export async function load({ params, fetch, cookies }) {
82
+ const client = createClient({ fetch, cookies });
83
+
84
+ const page = await client.getSingle("${model.id}");
85
+
86
+ return {
87
+ page,
88
+ };
89
+ }
90
+
91
+ /* @type {import("./$types").EntryGenerator} */
92
+ export async function entries() {
93
+ return [{}]
94
+ }
95
+ `;
96
+ if (typescript) {
97
+ return model.repeatable ? repeatableTS : nonrepeatableTS;
98
+ }
99
+ return model.repeatable ? repeatableJS : nonrepeatableJS;
100
+ }
101
+ function componentFileTemplate(args) {
102
+ const { typescript, version } = args;
103
+ const v5TS = commonTags.source(_a || (_a = __template(['\n <script lang="ts">\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n import type { PageProps } from "./$types";\n\n const { data }: PageProps = $props();\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
104
+ const v5JS = commonTags.source(_b || (_b = __template(['\n <script>\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n\n /* @type {import("./$types").PageProps} */\n const { data } = $props();\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
105
+ const v4TS = commonTags.source(_c || (_c = __template(['\n <script lang="ts">\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n import type { PageData } from "./$types";\n\n export let data: PageData;\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
106
+ const v4JS = commonTags.source(_d || (_d = __template(['\n <script>\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n\n /* @type {import("./$types").PageData} */\n export let data;\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
107
+ if (typescript) {
108
+ return version <= 4 ? v4TS : v5TS;
109
+ }
110
+ return version <= 4 ? v4JS : v5JS;
111
+ }
112
+ exports.componentFileTemplate = componentFileTemplate;
113
+ exports.dataFileTemplate = dataFileTemplate;
114
+ //# sourceMappingURL=documentation-read.templates.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentation-read.templates.cjs","sources":["../../../src/hooks/documentation-read.templates.ts"],"sourcesContent":["import { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport { source as svelte, source as ts, source as js } from \"common-tags\";\n\nexport function dataFileTemplate(args: {\n\tmodel: CustomType;\n\ttypescript: boolean;\n}): string {\n\tconst { model, typescript } = args;\n\n\tconst repeatableTS = ts`\n\t\timport { createClient } from \"$lib/prismicio\";\n\t\timport type { PageServerLoad, EntryGenerator } from './$types';\n\n\t\texport const load: PageServerLoad = async ({ params, fetch, cookies }) => {\n\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\treturn {\n\t\t\t\tpage,\n\t\t\t};\n\t\t}\n\n\t\texport const entries: EntryGenerator = async () => {\n\t\t\tconst client = createClient();\n\n\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\treturn pages.map((page) => {\n\t\t\t\treturn { uid: page.uid };\n\t\t\t});\n\t\t}\n\t`;\n\n\tconst nonrepeatableTS = ts`\n\t\timport { createClient } from \"$lib/prismicio\";\n\t\timport type { PageServerLoad, EntryGenerator } from './$types';\n\n\t\texport const load: PageServerLoad = async ({ params, fetch, cookies }) => {\n\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\treturn {\n\t\t\t\tpage,\n\t\t\t};\n\t\t}\n\n\t\texport const entries: EntryGenerator = async () => {\n\t\t\treturn [{}]\n\t\t}\n\t`;\n\n\tconst repeatableJS = js`\n\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t/* @type {import(\"./$types\").PageServerLoad} */\n\t\texport async function load({ params, fetch, cookies }) {\n\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\treturn {\n\t\t\t\tpage,\n\t\t\t};\n\t\t}\n\n\t\t/* @type {import(\"./$types\").EntryGenerator} */\n\t\texport async function entries() {\n\t\t\tconst client = createClient();\n\n\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\treturn pages.map((page) => {\n\t\t\t\treturn { uid: page.uid };\n\t\t\t});\n\t\t}\n\t`;\n\n\tconst nonrepeatableJS = js`\n\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t/* @type {import(\"./$types\").PageServerLoad} */\n\t\texport async function load({ params, fetch, cookies }) {\n\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\treturn {\n\t\t\t\tpage,\n\t\t\t};\n\t\t}\n\n\t\t/* @type {import(\"./$types\").EntryGenerator} */\n\t\texport async function entries() {\n\t\t\treturn [{}]\n\t\t}\n\t`;\n\n\tif (typescript) {\n\t\treturn model.repeatable ? repeatableTS : nonrepeatableTS;\n\t}\n\n\treturn model.repeatable ? repeatableJS : nonrepeatableJS;\n}\n\nexport function componentFileTemplate(args: {\n\ttypescript: boolean;\n\tversion: number;\n}): string {\n\tconst { typescript, version } = args;\n\n\tconst v5TS = svelte`\n\t\t<script lang=\"ts\">\n\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\timport { components } from \"$lib/slices\";\n\t\t\timport type { PageProps } from \"./$types\";\n\n\t\t\tconst { data }: PageProps = $props();\n\t\t</script>\n\n\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t`;\n\n\tconst v5JS = svelte`\n\t\t<script>\n\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\timport { components } from \"$lib/slices\";\n\n\t\t\t/* @type {import(\"./$types\").PageProps} */\n\t\t\tconst { data } = $props();\n\t\t</script>\n\n\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t`;\n\n\tconst v4TS = svelte`\n\t\t<script lang=\"ts\">\n\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\timport { components } from \"$lib/slices\";\n\t\t\timport type { PageData } from \"./$types\";\n\n\t\t\texport let data: PageData;\n\t\t</script>\n\n\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t`;\n\n\tconst v4JS = svelte`\n\t\t<script>\n\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\timport { components } from \"$lib/slices\";\n\n\t\t\t/* @type {import(\"./$types\").PageData} */\n\t\t\texport let data;\n\t\t</script>\n\n\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t`;\n\n\tif (typescript) {\n\t\treturn version <= 4 ? v4TS : v5TS;\n\t}\n\n\treturn version <= 4 ? v4JS : v5JS;\n}\n"],"names":["ts","js","svelte"],"mappings":";;;;;;AACA,IAAA,IAAA,IAAA,IAAA;AAEM,SAAU,iBAAiB,MAGhC;AACM,QAAA,EAAE,OAAO,WAAe,IAAA;AAE9B,QAAM,eAAeA,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,yCAOmB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8CAUH,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQrD,QAAM,kBAAkBA,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,0CAOiB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYjD,QAAM,eAAeC,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,yCAOmB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8CAWH,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQrD,QAAM,kBAAkBA,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,0CAOiB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAajD,MAAI,YAAY;AACR,WAAA,MAAM,aAAa,eAAe;AAAA,EAC1C;AAEO,SAAA,MAAM,aAAa,eAAe;AAC1C;AAEM,SAAU,sBAAsB,MAGrC;AACM,QAAA,EAAE,YAAY,QAAY,IAAA;AAEhC,QAAM,OAAOC,WAAM,OAAA,OAAA,KAAA,WAAA,CAAA,sSAAA,CAAA,EAAA;AAanB,QAAM,OAAOA,WAAM,OAAA,OAAA,KAAA,WAAA,CAAA,iRAAA,CAAA,EAAA;AAanB,QAAM,OAAOA,WAAM,OAAA,OAAA,KAAA,WAAA,CAAA,0RAAA,CAAA,EAAA;AAanB,QAAM,OAAOA,WAAM,OAAA,OAAA,KAAA,WAAA,CAAA,sQAAA,CAAA,EAAA;AAanB,MAAI,YAAY;AACR,WAAA,WAAW,IAAI,OAAO;AAAA,EAC9B;AAEO,SAAA,WAAW,IAAI,OAAO;AAC9B;;;"}
@@ -0,0 +1,9 @@
1
+ import { CustomType } from "@prismicio/types-internal/lib/customtypes";
2
+ export declare function dataFileTemplate(args: {
3
+ model: CustomType;
4
+ typescript: boolean;
5
+ }): string;
6
+ export declare function componentFileTemplate(args: {
7
+ typescript: boolean;
8
+ version: number;
9
+ }): string;