prismic 1.2.1 → 1.3.0
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/{builders-hKD4IrLX-cdTCGdwG.mjs → builders-hKD4IrLX-CiOmsZQP.mjs} +1 -1
- package/dist/index.mjs +119 -58
- package/dist/nextjs-c8JOjFCt.mjs +413 -0
- package/dist/nuxt-BhwnOusi.mjs +90 -0
- package/dist/string-CFNpwnbk.mjs +7 -0
- package/dist/sveltekit-BW5_-HtZ.mjs +263 -0
- package/package.json +1 -1
- package/src/adapters/index.ts +6 -0
- package/src/adapters/nextjs.templates.ts +170 -38
- package/src/adapters/nextjs.ts +33 -3
- package/src/adapters/nuxt.templates.ts +48 -0
- package/src/adapters/nuxt.ts +42 -20
- package/src/adapters/sveltekit.templates.ts +92 -35
- package/src/adapters/sveltekit.ts +38 -3
- package/src/auth.ts +1 -2
- package/src/clients/locale.ts +64 -0
- package/src/clients/user.ts +1 -0
- package/src/clients/wroom.ts +212 -0
- package/src/commands/gen-setup.ts +38 -0
- package/src/commands/gen-types.ts +35 -0
- package/src/commands/gen.ts +18 -0
- package/src/commands/init.ts +7 -1
- package/src/commands/locale-add.ts +47 -0
- package/src/commands/locale-list.ts +43 -0
- package/src/commands/locale-remove.ts +45 -0
- package/src/commands/locale-set-master.ts +61 -0
- package/src/commands/locale.ts +28 -0
- package/src/commands/repo-create.ts +60 -0
- package/src/commands/repo-list.ts +58 -0
- package/src/commands/repo-set-api-access.ts +53 -0
- package/src/commands/repo-set-name.ts +46 -0
- package/src/commands/repo-view.ts +74 -0
- package/src/commands/repo.ts +33 -0
- package/src/commands/sync.ts +4 -2
- package/src/commands/token-create.ts +55 -0
- package/src/commands/token-delete.ts +61 -0
- package/src/commands/token-list.ts +67 -0
- package/src/commands/token.ts +23 -0
- package/src/config.ts +53 -0
- package/src/env.ts +2 -0
- package/src/index.ts +20 -0
- package/src/lib/codegen.ts +6 -5
- package/src/lib/url.ts +7 -0
- package/dist/nextjs-DrbOdw3q.mjs +0 -318
- package/dist/nuxt-DO5Kp4yy.mjs +0 -59
- package/dist/string-CnZrLYLV.mjs +0 -7
- package/dist/sveltekit-KHG7YUoX.mjs +0 -236
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import{E as e,H as t,T as n,a as r,b as i,n as a,o,p as s,t as c,w as l,x as u,y as d}from"./string-CFNpwnbk.mjs";import{createRequire as f}from"node:module";import{fileURLToPath as p}from"node:url";import{relative as m}from"node:path";const h=c`
|
|
2
|
+
return (
|
|
3
|
+
<section
|
|
4
|
+
data-slice-type={slice.slice_type}
|
|
5
|
+
data-slice-variation={slice.variation}
|
|
6
|
+
>
|
|
7
|
+
Placeholder component for {slice.slice_type} (variation: {slice.variation}) slices.
|
|
8
|
+
<br />
|
|
9
|
+
<strong>You can edit this slice directly in your code editor.</strong>
|
|
10
|
+
</section>
|
|
11
|
+
)
|
|
12
|
+
`;function g(e){let{name:n,typescript:r}=e,i=t(n),a=c`
|
|
13
|
+
import { FC } from "react";
|
|
14
|
+
import { Content } from "@prismicio/client";
|
|
15
|
+
import { SliceComponentProps } from "@prismicio/react";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Props for \`${i}\`.
|
|
19
|
+
*/
|
|
20
|
+
export type ${i}Props = SliceComponentProps<Content.${i}Slice>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Component for "${n}" Slices.
|
|
24
|
+
*/
|
|
25
|
+
const ${i}: FC<${i}Props> = ({ slice }) => {
|
|
26
|
+
${h}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default ${i}
|
|
30
|
+
`,o=c`
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {import("@prismicio/client").Content.${i}Slice} ${i}Slice
|
|
33
|
+
* @typedef {import("@prismicio/react").SliceComponentProps<${i}Slice>} ${i}Props
|
|
34
|
+
* @type {import("react").FC<${i}Props>}
|
|
35
|
+
*/
|
|
36
|
+
const ${i} = ({ slice }) => {
|
|
37
|
+
${h}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default ${i};
|
|
41
|
+
`;return r?a:o}function _(e){let{model:t,routePath:n,typescript:r,appRouter:i}=e;return i?t.repeatable?r?c`
|
|
42
|
+
import { SliceZone } from "@prismicio/react";
|
|
43
|
+
import { createClient } from "@/prismicio";
|
|
44
|
+
import { components } from "@/slices";
|
|
45
|
+
|
|
46
|
+
export default async function Page({ params }: PageProps<"/${n}">) {
|
|
47
|
+
const { uid } = await params;
|
|
48
|
+
const client = createClient();
|
|
49
|
+
const page = await client.getByUID("${t.id}", uid);
|
|
50
|
+
|
|
51
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
52
|
+
}
|
|
53
|
+
`:c`
|
|
54
|
+
import { SliceZone } from "@prismicio/react";
|
|
55
|
+
import { createClient } from "@/prismicio";
|
|
56
|
+
import { components } from "@/slices";
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @type {PageProps<"/${n}">}
|
|
60
|
+
*/
|
|
61
|
+
export default async function Page({ params }) {
|
|
62
|
+
const { uid } = await params;
|
|
63
|
+
const client = createClient();
|
|
64
|
+
const page = await client.getByUID("${t.id}", uid);
|
|
65
|
+
|
|
66
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
67
|
+
}
|
|
68
|
+
`:c`
|
|
69
|
+
import { SliceZone } from "@prismicio/react";
|
|
70
|
+
import { createClient } from "@/prismicio";
|
|
71
|
+
import { components } from "@/slices";
|
|
72
|
+
|
|
73
|
+
export default async function Page() {
|
|
74
|
+
const client = createClient();
|
|
75
|
+
const page = await client.getSingle("${t.id}");
|
|
76
|
+
|
|
77
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
78
|
+
}
|
|
79
|
+
`:t.repeatable?r?c`
|
|
80
|
+
import type { InferGetStaticPropsType, GetStaticPropsContext } from "next";
|
|
81
|
+
import { SliceZone } from "@prismicio/react";
|
|
82
|
+
import { createClient } from "@/prismicio";
|
|
83
|
+
import { components } from "@/slices";
|
|
84
|
+
|
|
85
|
+
type Params = { uid: string };
|
|
86
|
+
|
|
87
|
+
export async function getStaticProps({ params, previewData }: GetStaticPropsContext<Params>) {
|
|
88
|
+
const client = createClient({ previewData });
|
|
89
|
+
const page = await client.getByUID("${t.id}", params.uid);
|
|
90
|
+
|
|
91
|
+
return { props: { page } };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default function Page({ page }: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
95
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function getStaticPaths() {
|
|
99
|
+
const client = createClient();
|
|
100
|
+
const pages = await client.getAllByType("${t.id}");
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
paths: pages.map((page) => ({ params: { uid: page.uid } })),
|
|
104
|
+
fallback: false,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
`:c`
|
|
108
|
+
import { SliceZone } from "@prismicio/react";
|
|
109
|
+
import { createClient } from "@/prismicio";
|
|
110
|
+
import { components } from "@/slices";
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {import("next").InferGetStaticPropsType<typeof getStaticProps>} props
|
|
114
|
+
*/
|
|
115
|
+
export default function Page({ page }) {
|
|
116
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function getStaticProps({ params, previewData }) {
|
|
120
|
+
const client = createClient({ previewData });
|
|
121
|
+
const page = await client.getByUID("${t.id}", params.uid);
|
|
122
|
+
|
|
123
|
+
return { props: { page } };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export async function getStaticPaths() {
|
|
127
|
+
const client = createClient();
|
|
128
|
+
const pages = await client.getAllByType("${t.id}");
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
paths: pages.map((page) => ({ params: { uid: page.uid } })),
|
|
132
|
+
fallback: false,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
`:r?c`
|
|
136
|
+
import type { InferGetStaticPropsType, GetStaticPropsContext } from "next";
|
|
137
|
+
import { SliceZone } from "@prismicio/react";
|
|
138
|
+
import { createClient } from "@/prismicio";
|
|
139
|
+
import { components } from "@/slices";
|
|
140
|
+
|
|
141
|
+
export async function getStaticProps({ previewData }: GetStaticPropsContext) {
|
|
142
|
+
const client = createClient({ previewData });
|
|
143
|
+
const page = await client.getSingle("${t.id}");
|
|
144
|
+
|
|
145
|
+
return { props: { page } };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default function Page({ page }: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
149
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
150
|
+
}
|
|
151
|
+
`:c`
|
|
152
|
+
import { SliceZone } from "@prismicio/react";
|
|
153
|
+
import { createClient } from "@/prismicio";
|
|
154
|
+
import { components } from "@/slices";
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @param {import("next").InferGetStaticPropsType<typeof getStaticProps>} props
|
|
158
|
+
*/
|
|
159
|
+
export default function Page({ page }) {
|
|
160
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export async function getStaticProps({ previewData }) {
|
|
164
|
+
const client = createClient({ previewData });
|
|
165
|
+
const page = await client.getSingle("${t.id}");
|
|
166
|
+
|
|
167
|
+
return { props: { page } };
|
|
168
|
+
}
|
|
169
|
+
`}function v(e){let{typescript:t,appRouter:n,hasSrcDirectory:r}=e,i=`${r?`..`:`.`}/prismic.config.json`,a,o;return n?t?(a=c`
|
|
170
|
+
import {
|
|
171
|
+
createClient as baseCreateClient,
|
|
172
|
+
type ClientConfig,
|
|
173
|
+
} from "@prismicio/client";
|
|
174
|
+
import { enableAutoPreviews } from "@prismicio/next";
|
|
175
|
+
import prismicConfig from "${i}";
|
|
176
|
+
`,o=c`
|
|
177
|
+
/**
|
|
178
|
+
* Creates a Prismic client for the project's repository. The client is used to
|
|
179
|
+
* query content from the Prismic API.
|
|
180
|
+
*
|
|
181
|
+
* @param config - Configuration for the Prismic client.
|
|
182
|
+
*/
|
|
183
|
+
export const createClient = (config: ClientConfig = {}) => {
|
|
184
|
+
const client = baseCreateClient(repositoryName, {
|
|
185
|
+
routes: prismicConfig.routes,
|
|
186
|
+
fetchOptions:
|
|
187
|
+
process.env.NODE_ENV === 'production'
|
|
188
|
+
? { next: { tags: ['prismic'] }, cache: 'force-cache' }
|
|
189
|
+
: { next: { revalidate: 5 } },
|
|
190
|
+
...config,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
enableAutoPreviews({ client });
|
|
194
|
+
|
|
195
|
+
return client;
|
|
196
|
+
};
|
|
197
|
+
`):(a=c`
|
|
198
|
+
import { createClient as baseCreateClient } from "@prismicio/client";
|
|
199
|
+
import { enableAutoPreviews } from "@prismicio/next";
|
|
200
|
+
import prismicConfig from "${i}";
|
|
201
|
+
`,o=c`
|
|
202
|
+
/**
|
|
203
|
+
* Creates a Prismic client for the project's repository. The client is used to
|
|
204
|
+
* query content from the Prismic API.
|
|
205
|
+
*
|
|
206
|
+
* @param {import("@prismicio/client").ClientConfig} config - Configuration for the Prismic client.
|
|
207
|
+
*/
|
|
208
|
+
export const createClient = (config = {}) => {
|
|
209
|
+
const client = baseCreateClient(repositoryName, {
|
|
210
|
+
routes: prismicConfig.routes,
|
|
211
|
+
fetchOptions:
|
|
212
|
+
process.env.NODE_ENV === 'production'
|
|
213
|
+
? { next: { tags: ['prismic'] }, cache: 'force-cache' }
|
|
214
|
+
: { next: { revalidate: 5 } },
|
|
215
|
+
...config,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
enableAutoPreviews({ client });
|
|
219
|
+
|
|
220
|
+
return client;
|
|
221
|
+
};
|
|
222
|
+
`):t?(a=c`
|
|
223
|
+
import { createClient as baseCreateClient } from "@prismicio/client";
|
|
224
|
+
import { enableAutoPreviews, type CreateClientConfig } from "@prismicio/next/pages";
|
|
225
|
+
import prismicConfig from "${i}";
|
|
226
|
+
`,o=c`
|
|
227
|
+
/**
|
|
228
|
+
* Creates a Prismic client for the project's repository. The client is used to
|
|
229
|
+
* query content from the Prismic API.
|
|
230
|
+
*
|
|
231
|
+
* @param config - Configuration for the Prismic client.
|
|
232
|
+
*/
|
|
233
|
+
export const createClient = ({ previewData, req, ...config }: CreateClientConfig = {}) => {
|
|
234
|
+
const client = baseCreateClient(repositoryName, {
|
|
235
|
+
routes: prismicConfig.routes,
|
|
236
|
+
...config,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
enableAutoPreviews({ client, previewData, req });
|
|
240
|
+
|
|
241
|
+
return client;
|
|
242
|
+
};
|
|
243
|
+
`):(a=c`
|
|
244
|
+
import { createClient as baseCreateClient } from "@prismicio/client";
|
|
245
|
+
import { enableAutoPreviews } from "@prismicio/next/pages";
|
|
246
|
+
import prismicConfig from "${i}";
|
|
247
|
+
`,o=c`
|
|
248
|
+
/**
|
|
249
|
+
* Creates a Prismic client for the project's repository. The client is used to
|
|
250
|
+
* query content from the Prismic API.
|
|
251
|
+
*
|
|
252
|
+
* @param {import("@prismicio/next/pages").CreateClientConfig} config - Configuration for the Prismic client.
|
|
253
|
+
*/
|
|
254
|
+
export const createClient = ({ previewData, req, ...config } = {}) => {
|
|
255
|
+
const client = baseCreateClient(repositoryName, {
|
|
256
|
+
routes: prismicConfig.routes,
|
|
257
|
+
...config,
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
enableAutoPreviews({ client, previewData, req });
|
|
261
|
+
|
|
262
|
+
return client;
|
|
263
|
+
};
|
|
264
|
+
`),t?c`
|
|
265
|
+
${a}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* The project's Prismic repository name.
|
|
269
|
+
*/
|
|
270
|
+
export const repositoryName = prismicConfig.repositoryName;
|
|
271
|
+
|
|
272
|
+
${o}
|
|
273
|
+
`:c`
|
|
274
|
+
${a}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The project's Prismic repository name.
|
|
278
|
+
*/
|
|
279
|
+
export const repositoryName = prismicConfig.repositoryName;
|
|
280
|
+
|
|
281
|
+
${o}
|
|
282
|
+
`}function y(e){let{typescript:t,appRouter:n}=e,r=c`
|
|
283
|
+
import { SliceSimulator, SliceSimulatorParams, getSlices } from "@prismicio/next";
|
|
284
|
+
import { SliceZone } from "@prismicio/react";
|
|
285
|
+
|
|
286
|
+
import { components } from "../../slices";
|
|
287
|
+
|
|
288
|
+
export default async function SliceSimulatorPage({
|
|
289
|
+
searchParams,
|
|
290
|
+
}: SliceSimulatorParams) {
|
|
291
|
+
const { state } = await searchParams
|
|
292
|
+
const slices = getSlices(state);
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<SliceSimulator>
|
|
296
|
+
<SliceZone slices={slices} components={components} />
|
|
297
|
+
</SliceSimulator>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
`,i=c`
|
|
301
|
+
import { SliceSimulator, getSlices } from "@prismicio/next";
|
|
302
|
+
import { SliceZone } from "@prismicio/react";
|
|
303
|
+
|
|
304
|
+
import { components } from "../../slices";
|
|
305
|
+
|
|
306
|
+
export default async function SliceSimulatorPage({ searchParams }) {
|
|
307
|
+
const { state } = await searchParams
|
|
308
|
+
const slices = getSlices(state);
|
|
309
|
+
|
|
310
|
+
return (
|
|
311
|
+
<SliceSimulator>
|
|
312
|
+
<SliceZone slices={slices} components={components} />
|
|
313
|
+
</SliceSimulator>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
`,a=c`
|
|
317
|
+
import { SliceSimulator } from "@prismicio/next/pages";
|
|
318
|
+
import { SliceZone } from "@prismicio/react";
|
|
319
|
+
|
|
320
|
+
import { components } from "../slices";
|
|
321
|
+
|
|
322
|
+
export default function SliceSimulatorPage() {
|
|
323
|
+
return (
|
|
324
|
+
<SliceSimulator
|
|
325
|
+
sliceZone={(props) => <SliceZone {...props} components={components} />}
|
|
326
|
+
/>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
`;return n?t?r:i:a}function b(e){let{typescript:t,appRouter:n}=e,r=c`
|
|
330
|
+
import { NextRequest } from "next/server";
|
|
331
|
+
import { redirectToPreviewURL } from "@prismicio/next";
|
|
332
|
+
|
|
333
|
+
import { createClient } from "../../../prismicio";
|
|
334
|
+
|
|
335
|
+
export async function GET(request: NextRequest) {
|
|
336
|
+
const client = createClient();
|
|
337
|
+
|
|
338
|
+
return await redirectToPreviewURL({ client, request });
|
|
339
|
+
}
|
|
340
|
+
`,i=c`
|
|
341
|
+
import { redirectToPreviewURL } from "@prismicio/next";
|
|
342
|
+
|
|
343
|
+
import { createClient } from "../../../prismicio";
|
|
344
|
+
|
|
345
|
+
export async function GET(request) {
|
|
346
|
+
const client = createClient();
|
|
347
|
+
|
|
348
|
+
return await redirectToPreviewURL({ client, request });
|
|
349
|
+
}
|
|
350
|
+
`,a=c`
|
|
351
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
352
|
+
import { setPreviewData, redirectToPreviewURL } from "@prismicio/next/pages";
|
|
353
|
+
|
|
354
|
+
import { createClient } from "../../prismicio";
|
|
355
|
+
|
|
356
|
+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
357
|
+
const client = createClient({ req });
|
|
358
|
+
|
|
359
|
+
setPreviewData({ req, res });
|
|
360
|
+
|
|
361
|
+
return await redirectToPreviewURL({ req, res, client });
|
|
362
|
+
};
|
|
363
|
+
`,o=c`
|
|
364
|
+
import { setPreviewData, redirectToPreviewURL } from "@prismicio/next/pages";
|
|
365
|
+
|
|
366
|
+
import { createClient } from "../../prismicio";
|
|
367
|
+
|
|
368
|
+
export default async function handler(req, res) {
|
|
369
|
+
const client = createClient({ req });
|
|
370
|
+
|
|
371
|
+
setPreviewData({ req, res });
|
|
372
|
+
|
|
373
|
+
return await redirectToPreviewURL({ req, res, client });
|
|
374
|
+
};
|
|
375
|
+
`;return n?t?r:i:t?a:o}function x(e){let{typescript:t,appRouter:n}=e,r=c`
|
|
376
|
+
import { exitPreview } from "@prismicio/next";
|
|
377
|
+
|
|
378
|
+
export function GET() {
|
|
379
|
+
return exitPreview();
|
|
380
|
+
}
|
|
381
|
+
`,i=c`
|
|
382
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
383
|
+
import { exitPreview } from "@prismicio/next/pages";
|
|
384
|
+
|
|
385
|
+
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
386
|
+
return exitPreview({ req, res });
|
|
387
|
+
}
|
|
388
|
+
`,a=c`
|
|
389
|
+
import { exitPreview } from "@prismicio/next/pages";
|
|
390
|
+
|
|
391
|
+
export default function handler(req, res) {
|
|
392
|
+
return exitPreview({ req, res });
|
|
393
|
+
}
|
|
394
|
+
`;return n?r:t?i:a}function S(e){let{supportsCacheLife:t}=e;return c`
|
|
395
|
+
import { NextResponse } from "next/server";
|
|
396
|
+
import { revalidateTag } from "next/cache";
|
|
397
|
+
|
|
398
|
+
export async function POST() {
|
|
399
|
+
revalidateTag("prismic"${t?`, "max"`:``});
|
|
400
|
+
|
|
401
|
+
return NextResponse.json({ revalidated: true, now: Date.now() });
|
|
402
|
+
}
|
|
403
|
+
`}var C=class extends a{id=`next`;async setupProject(){await d({"@prismicio/client":`^${await u(`@prismicio/client`)}`,"@prismicio/react":`^${await u(`@prismicio/react`)}`,"@prismicio/next":`^${await u(`@prismicio/next`)}`}),await O(),await D(),await E(),await T(),await w()}onProjectInitialized(){}async onSliceCreated(i,a){let o=t(i.name),s=new URL(o,e(a)),c=await N();await n(new URL(`index.${c}x`,e(s)),g({name:i.name,typescript:await r()}))}onSliceUpdated(){}onSliceDeleted(){}async onCustomTypeCreated(e){e.format===`page`&&await k(e)}onCustomTypeUpdated(){}onCustomTypeDeleted(){}async createSliceIndexFile(e){let r=(await this.getSlices()).filter(t=>t.library.href===e.href),i=r.map(n=>`import ${t(n.model.name)} from "./${m(p(e),p(n.directory))}";`),a=r.map(e=>{let n=t(e.model.name);return`${e.model.id}: ${n}`}),o=c`
|
|
404
|
+
// Code generated by Prismic. DO NOT EDIT.
|
|
405
|
+
|
|
406
|
+
${i.join(`
|
|
407
|
+
`)}
|
|
408
|
+
|
|
409
|
+
export const components = {
|
|
410
|
+
${a.join(`,
|
|
411
|
+
`)}
|
|
412
|
+
};
|
|
413
|
+
`,s=`index.${await N()}`;await n(new URL(s,e),o)}async getDefaultSliceLibrary(){let e=await o(),t=await M();return new URL(t?`src/slices/`:`slices/`,e)}};async function w(){if(!await A())return;let e=await j(),t=await N(),r=new URL(`app/api/revalidate/route.${t}`,e);if(await l(r))return;let i=await P();await n(r,S({supportsCacheLife:Number.parseInt(i.split(`.`)[0])>=16}))}async function T(){let e=await A(),t=await j(),i=await N(),a=new URL(e?`app/api/exit-preview/route.${i}`:`pages/api/exit-preview.${i}`,t);await l(a)||await n(a,x({typescript:await r(),appRouter:e}))}async function E(){let e=await A(),t=await j(),i=await N(),a=new URL(e?`app/api/preview/route.${i}`:`pages/api/preview.${i}`,t);await l(a)||await n(a,b({typescript:await r(),appRouter:e}))}async function D(){let e=await A(),t=await j(),i=`${await N()}x`,a=new URL(e?`app/slice-simulator/page.${i}`:`pages/slice-simulator.${i}`,t);await l(a)||await n(a,y({typescript:await r(),appRouter:e}))}async function O(){let e=await N(),t=await j(),i=new URL(`prismicio.${e}`,t);await l(i)||await n(i,v({typescript:await r(),appRouter:await A(),hasSrcDirectory:await M()}))}async function k(e){let t=s(e).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),i=await j(),a=`${await N()}x`,o=await A(),c=o?new URL(`app/${t}/page.${a}`,i):new URL(`pages/${t||`index`}.${a}`,i);await l(c)||await n(c,_({model:e,routePath:t,typescript:await r(),appRouter:o}))}async function A(){let e=await j();return await l(new URL(`app/`,e))}async function j(){let e=await o();return await M()?new URL(`src/`,e):e}async function M(){let e=await o();return l(new URL(`src/`,e))}async function N(){return await r()?`ts`:`js`}async function P(){let{version:e}=f(await i())(`next/package.json`);return e}export{C as NextJsAdapter};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import{E as e,H as t,T as n,a as r,g as i,n as a,o,p as s,t as c,v as l,w as u,x as d,y as f}from"./string-CFNpwnbk.mjs";import{n as p,r as m,t as h}from"./builders-hKD4IrLX-CiOmsZQP.mjs";import{readFile as g,rm as _}from"node:fs/promises";import{fileURLToPath as v}from"node:url";import{relative as y}from"node:path";function b(e){let{name:n,typescript:r}=e,i=t(n);return r?c`
|
|
2
|
+
<script setup lang="ts">
|
|
3
|
+
import type { Content } from "@prismicio/client";
|
|
4
|
+
|
|
5
|
+
// The array passed to \`getSliceComponentProps\` is purely optional.
|
|
6
|
+
// Consider it as a visual hint for you when templating your slice.
|
|
7
|
+
defineProps(getSliceComponentProps<Content.${i}Slice>(
|
|
8
|
+
["slice", "index", "slices", "context"]
|
|
9
|
+
));
|
|
10
|
+
<\/script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<section
|
|
14
|
+
:data-slice-type="slice.slice_type"
|
|
15
|
+
:data-slice-variation="slice.variation"
|
|
16
|
+
>
|
|
17
|
+
Placeholder component for {{ slice.slice_type }} (variation: {{ slice.variation }}) slices.
|
|
18
|
+
<br />
|
|
19
|
+
<strong>You can edit this slice directly in your code editor.</strong>
|
|
20
|
+
</section>
|
|
21
|
+
</template>
|
|
22
|
+
`:c`
|
|
23
|
+
<script setup>
|
|
24
|
+
// The array passed to \`getSliceComponentProps\` is purely optional.
|
|
25
|
+
// Consider it as a visual hint for you when templating your slice.
|
|
26
|
+
defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
|
|
27
|
+
<\/script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<section
|
|
31
|
+
:data-slice-type="slice.slice_type"
|
|
32
|
+
:data-slice-variation="slice.variation"
|
|
33
|
+
>
|
|
34
|
+
Placeholder component for {{ slice.slice_type }} (variation: {{ slice.variation }}) slices.
|
|
35
|
+
<br />
|
|
36
|
+
<strong>You can edit this slice directly in your code editor.</strong>
|
|
37
|
+
</section>
|
|
38
|
+
</template>
|
|
39
|
+
`}function x(e){let{model:t,typescript:n}=e,r=[`setup`];if(n&&r.push(`lang="ts"`),t.repeatable){let e=n?`route.params.uid as string`:`route.params.uid`;return c`
|
|
40
|
+
<script ${r.join(` `)}>
|
|
41
|
+
import { components } from "~/slices";
|
|
42
|
+
|
|
43
|
+
const prismic = usePrismic();
|
|
44
|
+
const route = useRoute();
|
|
45
|
+
const { data: page } = await useAsyncData(${e}, () =>
|
|
46
|
+
prismic.client.getByUID("${t.id}", ${e}),
|
|
47
|
+
);
|
|
48
|
+
<\/script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<main>
|
|
52
|
+
<SliceZone :slices="page?.data.slices ?? []" :components="components" />
|
|
53
|
+
</main>
|
|
54
|
+
</template>
|
|
55
|
+
`}return c`
|
|
56
|
+
<script ${r.join(` `)}>
|
|
57
|
+
import { components } from "~/slices";
|
|
58
|
+
|
|
59
|
+
const prismic = usePrismic();
|
|
60
|
+
const { data: page } = await useAsyncData("${t.id}", () =>
|
|
61
|
+
prismic.client.getSingle("${t.id}"),
|
|
62
|
+
);
|
|
63
|
+
<\/script>
|
|
64
|
+
|
|
65
|
+
<template>
|
|
66
|
+
<main>
|
|
67
|
+
<SliceZone :slices="page?.data.slices ?? []" :components="components" />
|
|
68
|
+
</main>
|
|
69
|
+
</template>
|
|
70
|
+
`}function S(e){let{typescript:t}=e,n=[`setup`];return t&&n.push(`lang="ts"`),c`
|
|
71
|
+
<script ${n.join(` `)}>
|
|
72
|
+
import { components } from "~/slices";
|
|
73
|
+
<\/script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<SliceSimulator #default="{ slices }">
|
|
77
|
+
<SliceZone :slices="slices" :components="components" />
|
|
78
|
+
</SliceSimulator>
|
|
79
|
+
</template>
|
|
80
|
+
`}const C=`@nuxtjs/prismic`;var w=class extends a{id=`nuxt`;async setupProject(){await f({"@prismicio/client":`^${await d(`@prismicio/client`)}`,[C]:`^${await d(C)}`}),await E(),await O(),await k(),await A(this)}onProjectInitialized(){}async onSliceCreated(i,a){let o=t(i.name),s=new URL(o,e(a));await n(new URL(`index.vue`,e(s)),b({name:i.name,typescript:await r()}))}onSliceUpdated(){}onSliceDeleted(){}async onCustomTypeCreated(e){e.format===`page`&&await j(e)}onCustomTypeUpdated(){}onCustomTypeDeleted(){}async createSliceIndexFile(e){let t=c`
|
|
81
|
+
// Code generated by Prismic. DO NOT EDIT.
|
|
82
|
+
|
|
83
|
+
import { defineAsyncComponent } from "vue";
|
|
84
|
+
import { defineSliceZoneComponents } from "@prismicio/vue";
|
|
85
|
+
|
|
86
|
+
export const components = defineSliceZoneComponents({
|
|
87
|
+
${(await this.getSlices()).filter(t=>t.library.href===e.href).map(t=>{let n=y(v(e),v(t.directory));return`${t.model.id}: defineAsyncComponent(() => import("./${n}/index.vue"))`}).join(`,
|
|
88
|
+
`)}
|
|
89
|
+
});
|
|
90
|
+
`,r=`index.${await M()}`;await n(new URL(r,e),t)}async getDefaultSliceLibrary(){let e=await T();return new URL(`slices/`,e)}};async function T(){let e=await o(),t=new URL(`app/`,e);if(await u(t))return t;let n=new URL(`src/`,e);return await u(n)?n:e}async function E(){let e=await o(),t=new URL(`nuxt.config.js`,e);if(await u(t)||(t=new URL(`nuxt.config.ts`,e)),!await u(t))return;let n=v(t),r=await p(n),i=r.exports.default.$type===`function-call`?r.exports.default.$args[0]:r.exports.default,a=!1;(i.modules||[]).find(e=>typeof e==`string`?e===C:Array.isArray(e)?(a=!!e[1],e[0]===C):!1)||(i.modules||=[],i.modules.push(C)),a||(r.imports.$prepend({from:`./prismic.config.json`,imported:`default`,local:`prismicConfig`}),i.prismic||={},i.prismic.endpoint=h.raw(`prismicConfig.repositoryName`),i.prismic.clientConfig||={},i.prismic.clientConfig.routes=h.raw(`prismicConfig.routes`)),await m(r,n)}async function D(){let e=await o(),t=new URL(`app/pages/`,e),n=new URL(`src/pages/`,e),r=new URL(`pages/`,e);return await u(t)?t:await u(n)?n:await u(r)?r:new URL(`pages/`,await T())}async function O(){let e=await r(),t=await D(),i=new URL(`slice-simulator.vue`,t);await u(i)||await n(i,S({typescript:e}))}async function k(){let e=await T(),t=new URL(`app.vue`,e);if(!await u(t))return;let r=await g(t,`utf8`);if(!r.includes(`<NuxtWelcome`))return;let i=new URL(`pages/index.vue`,e);await u(i)||await n(i,r),await _(t)}async function A(e){let t=await o(),n=await u(new URL(`app/`,t)),r=await u(new URL(`src/`,t));if(!n&&!r)return;let a;try{a=await i()}catch{return}let s=a.libraries;!s||JSON.stringify(s)!==JSON.stringify([`./slices`])||(await e.getSlices()).length>0||await l({libraries:[n?`./app/slices`:`./src/slices`]})}async function j(e){let t=s(e).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),i=await D(),a=new URL(`${t||`index`}.vue`,i);await u(a)||await n(a,x({model:e,typescript:await r()}))}async function M(){return await r()?`ts`:`js`}export{w as NuxtAdapter};
|