@slicemachine/adapter-sveltekit 0.3.18-dev-next-release.2 → 0.3.18-dev-next-release.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,189 @@
1
+ <script>
2
+ import { PrismicImage, PrismicRichText } from "@prismicio/svelte";
3
+ import { isFilled } from "@prismicio/client";
4
+
5
+ /**
6
+ * @type {import("@prismicio/client").Content.${PascalNameToReplace}Slice}
7
+ */
8
+ export let slice;
9
+ </script>
10
+
11
+ <section
12
+ data-slice-type={slice.slice_type}
13
+ data-slice-variation={slice.variation}
14
+ class="es-bounded es-fullpage-hero"
15
+ >
16
+ <div
17
+ class={`
18
+ es-bounded__content
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
+ {#if isFilled.image(slice.primary.image)}
28
+ <div>
29
+ <PrismicImage
30
+ field={slice.primary.image}
31
+ class="es-fullpage-hero__image"
32
+ />
33
+ </div>
34
+ {/if}
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
+ </div>
53
+ </div>
54
+ </div>
55
+
56
+ <style>
57
+ .es-bounded {
58
+ margin: 0px;
59
+ min-width: 0px;
60
+ position: relative;
61
+ }
62
+
63
+ .es-bounded-content {
64
+ min-width: 0px;
65
+ max-width: 90%;
66
+ margin: 0px auto;
67
+ }
68
+
69
+ .es-fullpage-hero {
70
+ font-family: system-ui, sans-serif;
71
+ background-color: #fff;
72
+ color: #333;
73
+ }
74
+
75
+ .es-fullpage-hero__image {
76
+ max-width: 100%;
77
+ height: auto;
78
+ align-self: center;
79
+ }
80
+
81
+ .es-fullpage-hero__image--left > div:first-child {
82
+ order: 1;
83
+ }
84
+
85
+ .es-fullpage-hero__image--left > div:nth-child(2) {
86
+ order: 2;
87
+ }
88
+
89
+ .es-fullpage-hero__image--right > div:first-child {
90
+ order: 2;
91
+ }
92
+
93
+ .es-fullpage-hero__image--right > div:nth-child(2) {
94
+ order: 1;
95
+ }
96
+
97
+ .es-fullpage-hero__content {
98
+ display: flex;
99
+ flex-direction: column;
100
+ gap: 2rem;
101
+ }
102
+
103
+ .es-fullpage-hero__content-right {
104
+ display: flex;
105
+ flex-direction: column;
106
+ justify-content: space-around;
107
+ padding: 1.5rem;
108
+ }
109
+
110
+ @media (min-width: 1080px) {
111
+ .es-fullpage-hero__content {
112
+ flex-direction: row;
113
+ }
114
+
115
+ .es-fullpage-hero__content > div {
116
+ width: 50%;
117
+ }
118
+ }
119
+
120
+ .es-fullpage-hero__content__intro {
121
+ display: grid;
122
+ gap: 1rem;
123
+ }
124
+
125
+ .es-fullpage-hero__content__intro__eyebrow {
126
+ color: #47c1af;
127
+ font-size: 1.15rem;
128
+ font-weight: 500;
129
+ margin: 0;
130
+ }
131
+
132
+ .es-fullpage-hero__content__intro__headline {
133
+ font-size: 1.625rem;
134
+ font-weight: 700;
135
+ }
136
+
137
+ .es-fullpage-hero__content__intro__headline > * {
138
+ margin: 0;
139
+ }
140
+
141
+ @media (min-width: 640px) {
142
+ .es-fullpage-hero__content__intro__headline {
143
+ font-size: 2rem;
144
+ }
145
+ }
146
+
147
+ @media (min-width: 1024px) {
148
+ .es-fullpage-hero__content__intro__headline {
149
+ font-size: 2.5rem;
150
+ }
151
+ }
152
+
153
+ @media (min-width: 1200px) {
154
+ .es-fullpage-hero__content__intro__headline {
155
+ font-size: 2.75rem;
156
+ }
157
+ }
158
+
159
+ .es-fullpage-hero__content__intro__description {
160
+ font-size: 1.15rem;
161
+ max-width: 38rem;
162
+ }
163
+
164
+ .es-fullpage-hero__content__intro__description > p {
165
+ margin: 0;
166
+ }
167
+
168
+ @media (min-width: 1200px) {
169
+ .es-fullpage-hero__content__intro__description {
170
+ font-size: 1.4rem;
171
+ }
172
+ }
173
+
174
+ .es-call-to-action__link {
175
+ justify-self: flex-start;
176
+ border-radius: 0.25rem;
177
+ font-size: 0.875rem;
178
+ line-height: 1.3;
179
+ padding: 1rem 2.625rem;
180
+ transition: background-color 100ms linear;
181
+ background-color: #16745f;
182
+ color: #fff;
183
+ }
184
+
185
+ .es-call-to-action__link:hover {
186
+ background-color: #0d5e4c;
187
+ }
188
+ </style>
189
+ </section>
Binary file
@@ -0,0 +1,187 @@
1
+ <script lang="ts">
2
+ import { PrismicImage, PrismicRichText } from "@prismicio/svelte";
3
+ import { isFilled } from "@prismicio/client";
4
+ import type { Content } from "@prismicio/client";
5
+
6
+ export let slice: Content.PascalNameToReplaceSlice;
7
+ </script>
8
+
9
+ <section
10
+ data-slice-type={slice.slice_type}
11
+ data-slice-variation={slice.variation}
12
+ class="es-bounded es-fullpage-hero"
13
+ >
14
+ <div
15
+ class={`
16
+ es-bounded__content
17
+ es-fullpage-hero__content
18
+ ${
19
+ slice.variation === "imageRight"
20
+ ? "es-fullpage-hero__image--right"
21
+ : "es-fullpage-hero__image--left"
22
+ }
23
+ `}
24
+ >
25
+ {#if isFilled.image(slice.primary.image)}
26
+ <div>
27
+ <PrismicImage
28
+ field={slice.primary.image}
29
+ class="es-fullpage-hero__image"
30
+ />
31
+ </div>
32
+ {/if}
33
+ <div class="es-fullpage-hero__content-right">
34
+ <div class="es-fullpage-hero__content__intro">
35
+ {#if isFilled.keyText(slice.primary.eyebrowHeadline)}
36
+ <p class="es-fullpage-hero__content__intro__eyebrow">
37
+ {slice.primary.eyebrowHeadline}
38
+ </p>
39
+ {/if}
40
+ {#if isFilled.richText(slice.primary.title)}
41
+ <div class="es-fullpage-hero__content__intro__headline">
42
+ <PrismicRichText field={slice.primary.title} />
43
+ </div>
44
+ {/if}
45
+ {#if isFilled.richText(slice.primary.description)}
46
+ <div class="es-fullpage-hero__content__intro__description">
47
+ <PrismicRichText field={slice.primary.description} />
48
+ </div>
49
+ {/if}
50
+ </div>
51
+ </div>
52
+ </div>
53
+
54
+ <style>
55
+ .es-bounded {
56
+ margin: 0px;
57
+ min-width: 0px;
58
+ position: relative;
59
+ }
60
+
61
+ .es-bounded-content {
62
+ min-width: 0px;
63
+ max-width: 90%;
64
+ margin: 0px auto;
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>
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const commonTags = require("common-tags");
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;
9
+ const nestRouteFilePath = (filePath, nesting) => {
10
+ return [
11
+ ...filePath.split("/").slice(0, 2),
12
+ nesting,
13
+ ...filePath.split("/").slice(2)
14
+ ].join("/");
15
+ };
16
+ const documentationRead = async (data, { options, helpers }) => {
17
+ if (data.kind === "PageSnippet") {
18
+ const { model } = data.data;
19
+ const pageDataExtension = await getJSFileExtension.getJSFileExtension({ helpers, options });
20
+ const routePath = `src/routes/${model.repeatable ? "[uid]" : model.id}`;
21
+ const dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;
22
+ 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 const prerender = true;
29
+
30
+ export async function load({ params, fetch }) {
31
+ const client = createClient({ fetch });
32
+
33
+ const page = await client.getByUID("${model.id}", params.uid);
34
+
35
+ return {
36
+ page,
37
+ };
38
+ }
39
+
40
+ export async function entries() {
41
+ const client = createClient();
42
+
43
+ const pages = await client.getAllByType("${model.id}");
44
+
45
+ return pages.map((page) => {
46
+ return { uid: page.uid };
47
+ });
48
+ }
49
+ `;
50
+ } else {
51
+ dataFileContent = commonTags.source`
52
+ import { createClient } from "$lib/prismicio";
53
+
54
+ export const prerender = true;
55
+
56
+ export async function load({ params, fetch }) {
57
+ const client = createClient({ fetch });
58
+
59
+ const page = await client.getSingle("${model.id}");
60
+
61
+ return {
62
+ page,
63
+ };
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 '])));
68
+ if (options.format) {
69
+ dataFileContent = await helpers.format(dataFileContent, helpers.joinPathFromRoot(dataFilePath), {
70
+ includeNewlineAtEnd: false
71
+ });
72
+ componentFileContent = await helpers.format(componentFileContent, helpers.joinPathFromRoot(componentFilePath), {
73
+ prettier: {
74
+ plugins: ["prettier-plugin-svelte"],
75
+ parser: "svelte"
76
+ },
77
+ includeNewlineAtEnd: false
78
+ });
79
+ }
80
+ const nestedDataFilePath = nestRouteFilePath(dataFilePath, "marketing");
81
+ const nestedComponentFilePath = nestRouteFilePath(componentFilePath, "marketing");
82
+ return [
83
+ {
84
+ label: "Default",
85
+ content: commonTags.source`
86
+ ## Create your ${model.label}'s page data fetcher
87
+
88
+ Add 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}\`.)
89
+
90
+ Paste in this code:
91
+
92
+ ${`~~~${pageDataExtension} [${dataFilePath}]
93
+ ${dataFileContent}
94
+ ~~~`}
95
+
96
+ ## Create your ${model.label}'s page component
97
+
98
+ In 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}\`.)
99
+
100
+ Paste in this code:
101
+
102
+ ${`~~~svelte [${componentFilePath}]
103
+ ${componentFileContent}
104
+ ~~~`}
105
+
106
+ Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.
107
+ `
108
+ }
109
+ ];
110
+ }
111
+ return [];
112
+ };
113
+ exports.documentationRead = documentationRead;
114
+ //# sourceMappingURL=documentation-read.cjs.map
@@ -0,0 +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 const prerender = true;\n\n\t\t\t\texport async function load({ params, fetch }) {\n\t\t\t\t\tconst client = createClient({ fetch });\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 const prerender = true;\n\n\t\t\t\texport async function load({ params, fetch }) {\n\t\t\t\t\tconst client = createClient({ fetch });\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\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,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A,UAClC,QAAQ;AAAA,QACR;AAAA,QACD,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEF;AAEK,UAAA,qBAAqB,kBAAkB,cAAc,WAAW;AAChE,UAAA,0BAA0B,kBAC/B,mBACA,WAAW;AAGL,WAAA;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAASA,WAAAA;AAAAA,sBACS,MAAM;AAAA;AAAA,uCAEW,4HAA4H;AAAA;AAAA;AAAA;AAAA,OAI5J,MAAM,sBAAsB;AAAA,EAAkB;AAAA;AAAA;AAAA,sBAE/B,MAAM;AAAA;AAAA,4CAEgB,iIAAiI;AAAA;AAAA;AAAA;AAAA,OAItK,cAAc;AAAA,EAAuB;AAAA;AAAA;AAAA;AAAA;AAAA,MAIxC;AAAA,IAAA;AAAA,EAEF;AAED,SAAO;AACR;;"}
@@ -0,0 +1,3 @@
1
+ import type { DocumentationReadHook } from "@slicemachine/plugin-kit";
2
+ import type { PluginOptions } from "../types";
3
+ export declare const documentationRead: DocumentationReadHook<PluginOptions>;
@@ -0,0 +1,114 @@
1
+ import { source } from "common-tags";
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;
7
+ const nestRouteFilePath = (filePath, nesting) => {
8
+ return [
9
+ ...filePath.split("/").slice(0, 2),
10
+ nesting,
11
+ ...filePath.split("/").slice(2)
12
+ ].join("/");
13
+ };
14
+ const documentationRead = async (data, { options, helpers }) => {
15
+ if (data.kind === "PageSnippet") {
16
+ const { model } = data.data;
17
+ const pageDataExtension = await getJSFileExtension({ helpers, options });
18
+ const routePath = `src/routes/${model.repeatable ? "[uid]" : model.id}`;
19
+ const dataFilePath = `${routePath}/+page.server.${pageDataExtension}`;
20
+ const componentFilePath = `${routePath}/+page.svelte`;
21
+ let dataFileContent;
22
+ if (model.repeatable) {
23
+ dataFileContent = source`
24
+ import { createClient } from "$lib/prismicio";
25
+
26
+ export const prerender = true;
27
+
28
+ export async function load({ params, fetch }) {
29
+ const client = createClient({ fetch });
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 = source`
50
+ import { createClient } from "$lib/prismicio";
51
+
52
+ export const prerender = true;
53
+
54
+ export async function load({ params, fetch }) {
55
+ const client = createClient({ fetch });
56
+
57
+ const page = await client.getSingle("${model.id}");
58
+
59
+ return {
60
+ page,
61
+ };
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 '])));
66
+ if (options.format) {
67
+ dataFileContent = await helpers.format(dataFileContent, helpers.joinPathFromRoot(dataFilePath), {
68
+ includeNewlineAtEnd: false
69
+ });
70
+ componentFileContent = await helpers.format(componentFileContent, helpers.joinPathFromRoot(componentFilePath), {
71
+ prettier: {
72
+ plugins: ["prettier-plugin-svelte"],
73
+ parser: "svelte"
74
+ },
75
+ includeNewlineAtEnd: false
76
+ });
77
+ }
78
+ const nestedDataFilePath = nestRouteFilePath(dataFilePath, "marketing");
79
+ const nestedComponentFilePath = nestRouteFilePath(componentFilePath, "marketing");
80
+ return [
81
+ {
82
+ label: "Default",
83
+ content: source`
84
+ ## Create your ${model.label}'s page data fetcher
85
+
86
+ Add 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}\`.)
87
+
88
+ Paste in this code:
89
+
90
+ ${`~~~${pageDataExtension} [${dataFilePath}]
91
+ ${dataFileContent}
92
+ ~~~`}
93
+
94
+ ## Create your ${model.label}'s page component
95
+
96
+ In 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}\`.)
97
+
98
+ Paste in this code:
99
+
100
+ ${`~~~svelte [${componentFilePath}]
101
+ ${componentFileContent}
102
+ ~~~`}
103
+
104
+ Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/svelte-install) for more information.
105
+ `
106
+ }
107
+ ];
108
+ }
109
+ return [];
110
+ };
111
+ export {
112
+ documentationRead
113
+ };
114
+ //# sourceMappingURL=documentation-read.js.map
@@ -0,0 +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 const prerender = true;\n\n\t\t\t\texport async function load({ params, fetch }) {\n\t\t\t\t\tconst client = createClient({ fetch });\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 const prerender = true;\n\n\t\t\t\texport async function load({ params, fetch }) {\n\t\t\t\t\tconst client = createClient({ fetch });\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\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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AA,EAEF;AAED,SAAO;AACR;"}
package/dist/plugin.cjs CHANGED
@@ -1,14 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const path = require("node:path");
4
+ const node_url = require("node:url");
3
5
  const pluginKit = require("@slicemachine/plugin-kit");
4
6
  const fs = require("@slicemachine/plugin-kit/fs");
5
7
  const rejectIfNecessary = require("./lib/rejectIfNecessary.cjs");
6
8
  const upsertSliceLibraryIndexFile = require("./lib/upsertSliceLibraryIndexFile.cjs");
7
9
  const _package = require("./packages/adapter-sveltekit/package.json.cjs");
10
+ const documentationRead = require("./hooks/documentation-read.cjs");
8
11
  const projectInit = require("./hooks/project-init.cjs");
9
12
  const sliceCreate = require("./hooks/slice-create.cjs");
10
13
  const sliceSimulatorSetupRead = require("./hooks/sliceSimulator-setup-read.cjs");
11
14
  const snippetRead = require("./hooks/snippet-read.cjs");
15
+ const index = require("./sliceTemplates/Hero/index.cjs");
12
16
  const plugin = pluginKit.defineSliceMachinePlugin({
13
17
  meta: {
14
18
  name: _package.name
@@ -110,6 +114,18 @@ const plugin = pluginKit.defineSliceMachinePlugin({
110
114
  ...context
111
115
  });
112
116
  });
117
+ hook("slice-template-library:read", async (data, context) => {
118
+ return await fs.readSliceTemplateLibrary({
119
+ ...data,
120
+ ...context,
121
+ dirName: path.dirname(node_url.fileURLToPath(new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : document.currentScript && document.currentScript.src || new URL("plugin.cjs", document.baseURI).href))),
122
+ templates: [index],
123
+ componentFileNames: {
124
+ js: "javascript.svelte",
125
+ ts: "typescript.svelte"
126
+ }
127
+ });
128
+ });
113
129
  hook("custom-type:create", async (data, context) => {
114
130
  await fs.writeCustomTypeModel({
115
131
  model: data.model,
@@ -194,9 +210,7 @@ const plugin = pluginKit.defineSliceMachinePlugin({
194
210
  });
195
211
  });
196
212
  hook("snippet:read", snippetRead.snippetRead);
197
- hook("documentation:read", async (_data, _context) => {
198
- return [];
199
- });
213
+ hook("documentation:read", documentationRead.documentationRead);
200
214
  hook("slice-simulator:setup:read", sliceSimulatorSetupRead.sliceSimulatorSetupRead);
201
215
  }
202
216
  });