@slicemachine/adapter-next 0.3.3-dev-next-release.2 → 0.3.3-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.
- package/dist/hooks/documentation-read.cjs +377 -0
- package/dist/hooks/documentation-read.cjs.map +1 -0
- package/dist/hooks/documentation-read.d.ts +3 -0
- package/dist/hooks/documentation-read.js +377 -0
- package/dist/hooks/documentation-read.js.map +1 -0
- package/dist/plugin.cjs +3 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +3 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/documentation-read.ts +395 -0
- package/src/plugin.ts +3 -2
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const commonTags = require("common-tags");
|
|
4
|
+
const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
|
|
5
|
+
const getJSFileExtension = require("../lib/getJSFileExtension.cjs");
|
|
6
|
+
const documentationRead = async (data, { options, helpers }) => {
|
|
7
|
+
const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
|
|
8
|
+
helpers,
|
|
9
|
+
options
|
|
10
|
+
});
|
|
11
|
+
if (data.kind === "PageSnippet") {
|
|
12
|
+
const { model } = data.data;
|
|
13
|
+
const extension = await getJSFileExtension.getJSFileExtension({ helpers, options, jsx: true });
|
|
14
|
+
const appFilePath = `${model.repeatable ? "[uid]" : model.id}/page.${extension}`;
|
|
15
|
+
const pagesFilePath = `${model.repeatable ? "[uid]" : model.id}.${extension}`;
|
|
16
|
+
let appFileContent;
|
|
17
|
+
let pagesFileContent;
|
|
18
|
+
if (isTypeScriptProject) {
|
|
19
|
+
if (model.repeatable) {
|
|
20
|
+
appFileContent = commonTags.stripIndent`
|
|
21
|
+
import { Metadata } from "next";
|
|
22
|
+
import { notFound } from "next/navigation";
|
|
23
|
+
import { SliceZone } from "@prismicio/react";
|
|
24
|
+
|
|
25
|
+
import { createClient } from "@/prismicio";
|
|
26
|
+
import { components } from "@/slices";
|
|
27
|
+
|
|
28
|
+
type Params = { uid: string };
|
|
29
|
+
|
|
30
|
+
export const dynamicParams = false;
|
|
31
|
+
|
|
32
|
+
export default async function Page({ params }: { params: Params }) {
|
|
33
|
+
const client = createClient();
|
|
34
|
+
const page = await client
|
|
35
|
+
.getByUID("${model.id}", params.uid)
|
|
36
|
+
.catch(() => notFound());
|
|
37
|
+
|
|
38
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function generateMetadata({
|
|
42
|
+
params,
|
|
43
|
+
}: {
|
|
44
|
+
params: Params;
|
|
45
|
+
}): Promise<Metadata> {
|
|
46
|
+
const client = createClient();
|
|
47
|
+
const page = await client.getByUID("${model.id}", params.uid);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
title: page.data.meta_title,
|
|
51
|
+
description: page.data.meta_description,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function generateStaticParams() {
|
|
56
|
+
const client = createClient();
|
|
57
|
+
const pages = await client.getAllByType("${model.id}");
|
|
58
|
+
|
|
59
|
+
return pages.map((page) => {
|
|
60
|
+
return { uid: page.uid };
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
pagesFileContent = commonTags.stripIndent`
|
|
65
|
+
import { GetStaticPropsContext, InferGetStaticPropsType } from "next";
|
|
66
|
+
import Head from "next/head";
|
|
67
|
+
import { isFilled, asLink } from "@prismicio/client";
|
|
68
|
+
import { SliceZone } from "@prismicio/react";
|
|
69
|
+
|
|
70
|
+
import { components } from "@/slices";
|
|
71
|
+
import { createClient } from "@/prismicio";
|
|
72
|
+
|
|
73
|
+
type Params = { uid: string };
|
|
74
|
+
|
|
75
|
+
export default function Page({
|
|
76
|
+
page,
|
|
77
|
+
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<Head>
|
|
81
|
+
<title>{page.data.meta_title}</title>
|
|
82
|
+
{isFilled.keyText(page.data.meta_description) ? (
|
|
83
|
+
<meta name="description" content={page.data.meta_description} />
|
|
84
|
+
) : null}
|
|
85
|
+
</Head>
|
|
86
|
+
<SliceZone slices={page.data.slices} components={components} />
|
|
87
|
+
</>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function getStaticProps({
|
|
92
|
+
params,
|
|
93
|
+
previewData,
|
|
94
|
+
}: GetStaticPropsContext<Params>) {
|
|
95
|
+
// The \`previewData\` parameter allows your app to preview
|
|
96
|
+
// drafts from the Page Builder.
|
|
97
|
+
const client = createClient({ previewData });
|
|
98
|
+
|
|
99
|
+
const page = await client.getByUID("${model.id}", params!.uid);
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
props: { page },
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function getStaticPaths() {
|
|
107
|
+
const client = createClient();
|
|
108
|
+
|
|
109
|
+
const pages = await client.getAllByType("${model.id}");
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
paths: pages.map((page) => {
|
|
113
|
+
return asLink(page);
|
|
114
|
+
}),
|
|
115
|
+
fallback: false,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
} else {
|
|
120
|
+
appFileContent = commonTags.stripIndent`
|
|
121
|
+
import { Metadata } from "next";
|
|
122
|
+
import { SliceZone } from "@prismicio/react";
|
|
123
|
+
|
|
124
|
+
import { createClient } from "@/prismicio";
|
|
125
|
+
import { components } from "@/slices";
|
|
126
|
+
|
|
127
|
+
export default async function Page() {
|
|
128
|
+
const client = createClient();
|
|
129
|
+
const page = await client.getSingle("${model.id}");
|
|
130
|
+
|
|
131
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
135
|
+
const client = createClient();
|
|
136
|
+
const page = await client.getSingle("${model.id}");
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
title: page.data.meta_title,
|
|
140
|
+
description: page.data.meta_description,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
pagesFileContent = commonTags.stripIndent`
|
|
145
|
+
import { GetStaticPropsContext, InferGetStaticPropsType } from "next";
|
|
146
|
+
import Head from "next/head";
|
|
147
|
+
import { isFilled } from "@prismicio/client";
|
|
148
|
+
import { SliceZone } from "@prismicio/react";
|
|
149
|
+
|
|
150
|
+
import { components } from "@/slices";
|
|
151
|
+
import { createClient } from "@/prismicio";
|
|
152
|
+
|
|
153
|
+
export default function Page({
|
|
154
|
+
page,
|
|
155
|
+
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
156
|
+
return (
|
|
157
|
+
<>
|
|
158
|
+
<Head>
|
|
159
|
+
<title>{page.data.meta_title}</title>
|
|
160
|
+
{isFilled.keyText(page.data.meta_description) ? (
|
|
161
|
+
<meta name="description" content={page.data.meta_description} />
|
|
162
|
+
) : null}
|
|
163
|
+
</Head>
|
|
164
|
+
<SliceZone slices={page.data.slices} components={components} />
|
|
165
|
+
</>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export async function getStaticProps({ previewData }: GetStaticPropsContext) {
|
|
170
|
+
// The \`previewData\` parameter allows your app to preview
|
|
171
|
+
// drafts from the Page Builder.
|
|
172
|
+
const client = createClient({ previewData });
|
|
173
|
+
|
|
174
|
+
// The query fetches the page's data based on the current URL.
|
|
175
|
+
const page = await client.getSingle("${model.id}");
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
props: { page },
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
if (model.repeatable) {
|
|
185
|
+
appFileContent = commonTags.stripIndent`
|
|
186
|
+
import { notFound } from "next/navigation";
|
|
187
|
+
import { SliceZone } from "@prismicio/react";
|
|
188
|
+
|
|
189
|
+
import { createClient } from "@/prismicio";
|
|
190
|
+
import { components } from "@/slices";
|
|
191
|
+
|
|
192
|
+
export const dynamicParams = false;
|
|
193
|
+
|
|
194
|
+
export default async function Page({ params }) {
|
|
195
|
+
const client = createClient();
|
|
196
|
+
const page = await client
|
|
197
|
+
.getByUID("${model.id}", params.uid)
|
|
198
|
+
.catch(() => notFound());
|
|
199
|
+
|
|
200
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export async function generateMetadata({ params }) {
|
|
204
|
+
const client = createClient();
|
|
205
|
+
const page = await client.getByUID("${model.id}", params.uid);
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
title: page.data.meta_title,
|
|
209
|
+
description: page.data.meta_description,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export async function generateStaticParams() {
|
|
214
|
+
const client = createClient();
|
|
215
|
+
const pages = await client.getAllByType("${model.id}");
|
|
216
|
+
|
|
217
|
+
return pages.map((page) => {
|
|
218
|
+
return { uid: page.uid };
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
`;
|
|
222
|
+
pagesFileContent = commonTags.stripIndent`
|
|
223
|
+
import Head from "next/head";
|
|
224
|
+
import { isFilled, asLink } from "@prismicio/client";
|
|
225
|
+
import { SliceZone } from "@prismicio/react";
|
|
226
|
+
|
|
227
|
+
import { components } from "@/slices";
|
|
228
|
+
import { createClient } from "@/prismicio";
|
|
229
|
+
|
|
230
|
+
export default function Page({ page }) {
|
|
231
|
+
return (
|
|
232
|
+
<>
|
|
233
|
+
<Head>
|
|
234
|
+
<title>{page.data.meta_title}</title>
|
|
235
|
+
{isFilled.keyText(page.data.meta_description) ? (
|
|
236
|
+
<meta name="description" content={page.data.meta_description} />
|
|
237
|
+
) : null}
|
|
238
|
+
</Head>
|
|
239
|
+
<SliceZone slices={page.data.slices} components={components} />
|
|
240
|
+
</>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export async function getStaticProps({
|
|
245
|
+
params,
|
|
246
|
+
previewData,
|
|
247
|
+
}) {
|
|
248
|
+
// The \`previewData\` parameter allows your app to preview
|
|
249
|
+
// drafts from the Page Builder.
|
|
250
|
+
const client = createClient({ previewData });
|
|
251
|
+
|
|
252
|
+
const page = await client.getByUID("${model.id}", params.uid);
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
props: { page },
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export async function getStaticPaths() {
|
|
260
|
+
const client = createClient();
|
|
261
|
+
|
|
262
|
+
const pages = await client.getAllByType("${model.id}");
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
paths: pages.map((page) => {
|
|
266
|
+
return asLink(page);
|
|
267
|
+
}),
|
|
268
|
+
fallback: false,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
`;
|
|
272
|
+
} else {
|
|
273
|
+
appFileContent = commonTags.stripIndent`
|
|
274
|
+
import { SliceZone } from "@prismicio/react";
|
|
275
|
+
|
|
276
|
+
import { createClient } from "@/prismicio";
|
|
277
|
+
import { components } from "@/slices";
|
|
278
|
+
|
|
279
|
+
export default async function Page() {
|
|
280
|
+
const client = createClient();
|
|
281
|
+
const page = await client.getSingle("${model.id}");
|
|
282
|
+
|
|
283
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export async function generateMetadata() {
|
|
287
|
+
const client = createClient();
|
|
288
|
+
const page = await client.getSingle("${model.id}");
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
title: page.data.meta_title,
|
|
292
|
+
description: page.data.meta_description,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
`;
|
|
296
|
+
pagesFileContent = commonTags.stripIndent`
|
|
297
|
+
import Head from "next/head";
|
|
298
|
+
import { isFilled } from "@prismicio/client";
|
|
299
|
+
import { SliceZone } from "@prismicio/react";
|
|
300
|
+
|
|
301
|
+
import { components } from "@/slices";
|
|
302
|
+
import { createClient } from "@/prismicio";
|
|
303
|
+
|
|
304
|
+
export default function Page({ page }) {
|
|
305
|
+
return (
|
|
306
|
+
<>
|
|
307
|
+
<Head>
|
|
308
|
+
<title>{page.data.meta_title}</title>
|
|
309
|
+
{isFilled.keyText(page.data.meta_description) ? (
|
|
310
|
+
<meta name="description" content={page.data.meta_description} />
|
|
311
|
+
) : null}
|
|
312
|
+
</Head>
|
|
313
|
+
<SliceZone slices={page.data.slices} components={components} />
|
|
314
|
+
</>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export async function getStaticProps({ previewData }) {
|
|
319
|
+
// The \`previewData\` parameter allows your app to preview
|
|
320
|
+
// drafts from the Page Builder.
|
|
321
|
+
const client = createClient({ previewData });
|
|
322
|
+
|
|
323
|
+
// The query fetches the page's data based on the current URL.
|
|
324
|
+
const page = await client.getSingle("${model.id}");
|
|
325
|
+
|
|
326
|
+
return {
|
|
327
|
+
props: { page },
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
`;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (options.format) {
|
|
334
|
+
appFileContent = await helpers.format(appFileContent, helpers.joinPathFromRoot(`index.${extension}`), {
|
|
335
|
+
includeNewlineAtEnd: false
|
|
336
|
+
});
|
|
337
|
+
pagesFileContent = await helpers.format(pagesFileContent, helpers.joinPathFromRoot(`index.${extension}`), {
|
|
338
|
+
includeNewlineAtEnd: false
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
return [
|
|
342
|
+
{
|
|
343
|
+
label: "App Router",
|
|
344
|
+
content: commonTags.source`
|
|
345
|
+
## Create your ${model.label}'s page component
|
|
346
|
+
|
|
347
|
+
Add a new route by creating an \`app/${appFilePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`app/marketing/${appFilePath}\`.)
|
|
348
|
+
|
|
349
|
+
Paste in this code:
|
|
350
|
+
|
|
351
|
+
${`~~~${extension} [app/${appFilePath}]
|
|
352
|
+
${appFileContent}
|
|
353
|
+
~~~`}
|
|
354
|
+
|
|
355
|
+
Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/setup-nextjs) for more information.
|
|
356
|
+
`
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
label: "Page Router",
|
|
360
|
+
content: commonTags.source`
|
|
361
|
+
## Create your ${model.label}'s page component
|
|
362
|
+
|
|
363
|
+
Add a new route by creating a \`pages/${pagesFilePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`pages/marketing/${pagesFilePath}\`.)
|
|
364
|
+
|
|
365
|
+
${`~~~${extension} [pages/${pagesFilePath}]
|
|
366
|
+
${pagesFileContent}
|
|
367
|
+
~~~`}
|
|
368
|
+
|
|
369
|
+
Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/setup-nextjs) for more information.
|
|
370
|
+
`
|
|
371
|
+
}
|
|
372
|
+
];
|
|
373
|
+
}
|
|
374
|
+
return [];
|
|
375
|
+
};
|
|
376
|
+
exports.documentationRead = documentationRead;
|
|
377
|
+
//# sourceMappingURL=documentation-read.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation-read.cjs","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { stripIndent, source } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\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 extension = await getJSFileExtension({ helpers, options, jsx: true });\n\n\t\tconst appFilePath = `${\n\t\t\tmodel.repeatable ? \"[uid]\" : model.id\n\t\t}/page.${extension}`;\n\t\tconst pagesFilePath = `${\n\t\t\tmodel.repeatable ? \"[uid]\" : model.id\n\t\t}.${extension}`;\n\n\t\tlet appFileContent: string;\n\t\tlet pagesFileContent: string;\n\t\tif (isTypeScriptProject) {\n\t\t\tif (model.repeatable) {\n\t\t\t\tappFileContent = stripIndent`\n\t\t\t\t\timport { Metadata } from \"next\";\n\t\t\t\t\timport { notFound } from \"next/navigation\";\n\t\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\t\timport { createClient } from \"@/prismicio\";\n\t\t\t\t\timport { components } from \"@/slices\";\n\n\t\t\t\t\ttype Params = { uid: string };\n\n\t\t\t\t\texport const dynamicParams = false;\n\n\t\t\t\t\texport default async function Page({ params }: { params: Params }) {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst page = await client\n\t\t\t\t\t\t\t.getByUID(\"${model.id}\", params.uid)\n\t\t\t\t\t\t\t.catch(() => notFound());\n\n\t\t\t\t\t\treturn <SliceZone slices={page.data.slices} components={components} />;\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function generateMetadata({\n\t\t\t\t\t\tparams,\n\t\t\t\t\t}: {\n\t\t\t\t\t\tparams: Params;\n\t\t\t\t\t}): Promise<Metadata> {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: page.data.meta_title,\n\t\t\t\t\t\t\tdescription: page.data.meta_description,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function generateStaticParams() {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\t\t\t\treturn pages.map((page) => {\n\t\t\t\t\t\t\treturn { uid: page.uid };\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t`;\n\t\t\t\tpagesFileContent = stripIndent`\n\t\t\t\t\timport { GetStaticPropsContext, InferGetStaticPropsType } from \"next\";\n\t\t\t\t\timport Head from \"next/head\";\n\t\t\t\t\timport { isFilled, asLink } from \"@prismicio/client\";\n\t\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\t\timport { components } from \"@/slices\";\n\t\t\t\t\timport { createClient } from \"@/prismicio\";\n\n\t\t\t\t\ttype Params = { uid: string };\n\n\t\t\t\t\texport default function Page({\n\t\t\t\t\t\tpage,\n\t\t\t\t\t}: InferGetStaticPropsType<typeof getStaticProps>) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Head>\n\t\t\t\t\t\t\t\t\t<title>{page.data.meta_title}</title>\n\t\t\t\t\t\t\t\t\t{isFilled.keyText(page.data.meta_description) ? (\n\t\t\t\t\t\t\t\t\t\t<meta name=\"description\" content={page.data.meta_description} />\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</Head>\n\t\t\t\t\t\t\t\t<SliceZone slices={page.data.slices} components={components} />\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function getStaticProps({\n\t\t\t\t\t\tparams,\n\t\t\t\t\t\tpreviewData,\n\t\t\t\t\t}: GetStaticPropsContext<Params>) {\n\t\t\t\t\t\t// The \\`previewData\\` parameter allows your app to preview\n\t\t\t\t\t\t// drafts from the Page Builder.\n\t\t\t\t\t\tconst client = createClient({ previewData });\n\n\t\t\t\t\t\tconst page = await client.getByUID(\"${model.id}\", params!.uid);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprops: { page },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function getStaticPaths() {\n\t\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tpaths: pages.map((page) => {\n\t\t\t\t\t\t\t\treturn asLink(page);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tfallback: false,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tappFileContent = stripIndent`\n\t\t\t\t\timport { Metadata } from \"next\";\n\t\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\t\timport { createClient } from \"@/prismicio\";\n\t\t\t\t\timport { components } from \"@/slices\";\n\n\t\t\t\t\texport default async function Page() {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\t\treturn <SliceZone slices={page.data.slices} components={components} />;\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function generateMetadata(): Promise<Metadata> {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: page.data.meta_title,\n\t\t\t\t\t\t\tdescription: page.data.meta_description,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t`;\n\t\t\t\tpagesFileContent = stripIndent`\n\t\t\t\t\timport { GetStaticPropsContext, InferGetStaticPropsType } from \"next\";\n\t\t\t\t\timport Head from \"next/head\";\n\t\t\t\t\timport { isFilled } from \"@prismicio/client\";\n\t\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\t\timport { components } from \"@/slices\";\n\t\t\t\t\timport { createClient } from \"@/prismicio\";\n\n\t\t\t\t\texport default function Page({\n\t\t\t\t\t\tpage,\n\t\t\t\t\t}: InferGetStaticPropsType<typeof getStaticProps>) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Head>\n\t\t\t\t\t\t\t\t\t<title>{page.data.meta_title}</title>\n\t\t\t\t\t\t\t\t\t{isFilled.keyText(page.data.meta_description) ? (\n\t\t\t\t\t\t\t\t\t\t<meta name=\"description\" content={page.data.meta_description} />\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</Head>\n\t\t\t\t\t\t\t\t<SliceZone slices={page.data.slices} components={components} />\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function getStaticProps({ previewData }: GetStaticPropsContext) {\n\t\t\t\t\t\t// The \\`previewData\\` parameter allows your app to preview\n\t\t\t\t\t\t// drafts from the Page Builder.\n\t\t\t\t\t\tconst client = createClient({ previewData });\n\n\t\t\t\t\t\t// The query fetches the page's data based on the current URL.\n\t\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprops: { page },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t`;\n\t\t\t}\n\t\t} else {\n\t\t\tif (model.repeatable) {\n\t\t\t\tappFileContent = stripIndent`\n\t\t\t\t\timport { notFound } from \"next/navigation\";\n\t\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\t\timport { createClient } from \"@/prismicio\";\n\t\t\t\t\timport { components } from \"@/slices\";\n\n\t\t\t\t\texport const dynamicParams = false;\n\n\t\t\t\t\texport default async function Page({ params }) {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst page = await client\n\t\t\t\t\t\t\t.getByUID(\"${model.id}\", params.uid)\n\t\t\t\t\t\t\t.catch(() => notFound());\n\n\t\t\t\t\t\treturn <SliceZone slices={page.data.slices} components={components} />;\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function generateMetadata({ params }) {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: page.data.meta_title,\n\t\t\t\t\t\t\tdescription: page.data.meta_description,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function generateStaticParams() {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\t\t\t\treturn pages.map((page) => {\n\t\t\t\t\t\t\treturn { uid: page.uid };\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t`;\n\t\t\t\tpagesFileContent = stripIndent`\n\t\t\t\t\timport Head from \"next/head\";\n\t\t\t\t\timport { isFilled, asLink } from \"@prismicio/client\";\n\t\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\t\timport { components } from \"@/slices\";\n\t\t\t\t\timport { createClient } from \"@/prismicio\";\n\n\t\t\t\t\texport default function Page({ page }) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Head>\n\t\t\t\t\t\t\t\t\t<title>{page.data.meta_title}</title>\n\t\t\t\t\t\t\t\t\t{isFilled.keyText(page.data.meta_description) ? (\n\t\t\t\t\t\t\t\t\t\t<meta name=\"description\" content={page.data.meta_description} />\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</Head>\n\t\t\t\t\t\t\t\t<SliceZone slices={page.data.slices} components={components} />\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function getStaticProps({\n\t\t\t\t\t\tparams,\n\t\t\t\t\t\tpreviewData,\n\t\t\t\t\t}) {\n\t\t\t\t\t\t// The \\`previewData\\` parameter allows your app to preview\n\t\t\t\t\t\t// drafts from the Page Builder.\n\t\t\t\t\t\tconst client = createClient({ previewData });\n\n\t\t\t\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprops: { page },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function getStaticPaths() {\n\t\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tpaths: pages.map((page) => {\n\t\t\t\t\t\t\t\treturn asLink(page);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tfallback: false,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tappFileContent = stripIndent`\n\t\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\t\timport { createClient } from \"@/prismicio\";\n\t\t\t\t\timport { components } from \"@/slices\";\n\n\t\t\t\t\texport default async function Page() {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\t\treturn <SliceZone slices={page.data.slices} components={components} />;\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function generateMetadata() {\n\t\t\t\t\t\tconst client = createClient();\n\t\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: page.data.meta_title,\n\t\t\t\t\t\t\tdescription: page.data.meta_description,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t`;\n\t\t\t\tpagesFileContent = stripIndent`\n\t\t\t\t\timport Head from \"next/head\";\n\t\t\t\t\timport { isFilled } from \"@prismicio/client\";\n\t\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\t\timport { components } from \"@/slices\";\n\t\t\t\t\timport { createClient } from \"@/prismicio\";\n\n\t\t\t\t\texport default function Page({ page }) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Head>\n\t\t\t\t\t\t\t\t\t<title>{page.data.meta_title}</title>\n\t\t\t\t\t\t\t\t\t{isFilled.keyText(page.data.meta_description) ? (\n\t\t\t\t\t\t\t\t\t\t<meta name=\"description\" content={page.data.meta_description} />\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</Head>\n\t\t\t\t\t\t\t\t<SliceZone slices={page.data.slices} components={components} />\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\texport async function getStaticProps({ previewData }) {\n\t\t\t\t\t\t// The \\`previewData\\` parameter allows your app to preview\n\t\t\t\t\t\t// drafts from the Page Builder.\n\t\t\t\t\t\tconst client = createClient({ previewData });\n\n\t\t\t\t\t\t// The query fetches the page's data based on the current URL.\n\t\t\t\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprops: { page },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t`;\n\t\t\t}\n\t\t}\n\n\t\tif (options.format) {\n\t\t\tappFileContent = await helpers.format(\n\t\t\t\tappFileContent,\n\t\t\t\thelpers.joinPathFromRoot(`index.${extension}`),\n\t\t\t\t{\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\tpagesFileContent = await helpers.format(\n\t\t\t\tpagesFileContent,\n\t\t\t\thelpers.joinPathFromRoot(`index.${extension}`),\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\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"App Router\",\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 \\`app/${appFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`app/marketing/${appFilePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~${extension} [app/${appFilePath}]\\n${appFileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/setup-nextjs) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"Page Router\",\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 a \\`pages/${pagesFilePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`pages/marketing/${pagesFilePath}\\`.)\n\n\t\t\t\t\t${`~~~${extension} [pages/${pagesFilePath}]\\n${pagesFileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/setup-nextjs) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":["checkIsTypeScriptProject","getJSFileExtension","stripIndent","source"],"mappings":";;;;;AAQO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACG,QAAA,sBAAsB,MAAMA,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAEG,MAAA,KAAK,SAAS,eAAe;AAC1B,UAAA,EAAE,MAAK,IAAK,KAAK;AACjB,UAAA,YAAY,MAAMC,mBAAAA,mBAAmB,EAAE,SAAS,SAAS,KAAK,MAAM;AAE1E,UAAM,cAAc,GACnB,MAAM,aAAa,UAAU,MAAM,WAC3B;AACT,UAAM,gBAAgB,GACrB,MAAM,aAAa,UAAU,MAAM,MAChC;AAEA,QAAA;AACA,QAAA;AACJ,QAAI,qBAAqB;AACxB,UAAI,MAAM,YAAY;AACJ,yBAAAC,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,oBAeD,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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