@nuxtjs/prismic 4.1.0 → 5.0.0-canary.130d8b9
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/LICENSE +1 -1
- package/README.md +18 -32
- package/dist/module.d.mts +48 -75
- package/dist/module.json +3 -3
- package/dist/module.mjs +215 -245
- package/dist/runtime/PrismicPreview.d.vue.ts +3 -0
- package/dist/runtime/PrismicPreview.vue +10 -23
- package/dist/runtime/PrismicPreview.vue.d.ts +3 -0
- package/dist/runtime/plugin.client.js +10 -7
- package/dist/runtime/plugin.js +86 -69
- package/dist/runtime/usePrismicPreview.d.ts +1 -5
- package/dist/runtime/usePrismicPreview.js +2 -2
- package/dist/types.d.mts +3 -1
- package/package.json +42 -44
- package/src/module.ts +382 -190
- package/src/runtime/PrismicPreview.vue +10 -41
- package/src/runtime/plugin.client.ts +13 -13
- package/src/runtime/plugin.ts +114 -103
- package/src/runtime/usePrismicPreview.ts +6 -10
- package/dist/client/200.html +0 -1
- package/dist/client/404.html +0 -1
- package/dist/client/_nuxt/72kwNbQb.js +0 -25
- package/dist/client/_nuxt/BOjifcfq.js +0 -1
- package/dist/client/_nuxt/Cg7-pAa1.js +0 -1
- package/dist/client/_nuxt/DjoQbwig.js +0 -1
- package/dist/client/_nuxt/DlAUqK2U.js +0 -1
- package/dist/client/_nuxt/X01cQnxr.js +0 -1
- package/dist/client/_nuxt/YYRUG_yD.js +0 -1
- package/dist/client/_nuxt/builds/latest.json +0 -1
- package/dist/client/_nuxt/builds/meta/b7611925-2a2f-4b3a-a8ca-80585b109dfa.json +0 -1
- package/dist/client/_nuxt/entry.BC9BDAld.css +0 -1
- package/dist/client/_nuxt/error-404.BgOy5onL.css +0 -1
- package/dist/client/_nuxt/error-500.Di0s_DEL.css +0 -1
- package/dist/client/_nuxt/index.C4BggqQh.css +0 -1
- package/dist/client/index.html +0 -1
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -136
- package/dist/types.d.ts +0 -1
- package/src/devtools/index.ts +0 -127
- package/src/devtools/types.ts +0 -22
- package/src/lib/fileExists.ts +0 -15
- package/src/lib/index.ts +0 -2
- package/src/lib/logger.ts +0 -3
- package/src/types.ts +0 -137
package/dist/module.mjs
CHANGED
|
@@ -1,295 +1,265 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
1
|
import { existsSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { useLogger, defineNuxtModule, createResolver, addPlugin, addComponent, addImports, extendPages, getNuxtVersion, addTemplate } from '@nuxt/kit';
|
|
4
5
|
import { defu } from 'defu';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { onDevToolsInitialized, extendServerRpc, startSubprocess } from '@nuxt/devtools-kit';
|
|
8
|
-
import { resolve } from 'pathe';
|
|
9
|
-
import terminate from 'terminate';
|
|
6
|
+
import { addDependency } from 'nypm';
|
|
7
|
+
import { readPackage } from 'pkg-types';
|
|
10
8
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
SliceMachineStatus2[SliceMachineStatus2["STARTED"] = 0] = "STARTED";
|
|
14
|
-
SliceMachineStatus2[SliceMachineStatus2["STOPPED"] = 1] = "STOPPED";
|
|
15
|
-
return SliceMachineStatus2;
|
|
16
|
-
})(SliceMachineStatus || {});
|
|
17
|
-
|
|
18
|
-
const DEVTOOLS_UI_ROUTE = "/__prismic-client";
|
|
19
|
-
const DEVTOOLS_UI_LOCAL_PORT = 5173;
|
|
20
|
-
let subProcess = null;
|
|
21
|
-
const stopSubprocess = () => {
|
|
22
|
-
if (subProcess) {
|
|
23
|
-
const pid = subProcess.getProcess().pid;
|
|
24
|
-
if (pid) {
|
|
25
|
-
terminate(pid);
|
|
26
|
-
}
|
|
27
|
-
subProcess.terminate();
|
|
28
|
-
subProcess = null;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const setupDevToolsUI = (nuxt, resolver) => {
|
|
32
|
-
const clientPath = resolver.resolve("./client");
|
|
33
|
-
const isProductionBuild = existsSync(clientPath);
|
|
34
|
-
if (isProductionBuild) {
|
|
35
|
-
nuxt.hook("vite:serverCreated", async (server) => {
|
|
36
|
-
const sirv = await import('sirv').then((r) => r.default || r);
|
|
37
|
-
server.middlewares.use(
|
|
38
|
-
DEVTOOLS_UI_ROUTE,
|
|
39
|
-
sirv(clientPath, { dev: true, single: true })
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
nuxt.hook("vite:extendConfig", (config) => {
|
|
44
|
-
config.server = config.server || {};
|
|
45
|
-
config.server.proxy = config.server.proxy || {};
|
|
46
|
-
config.server.proxy[DEVTOOLS_UI_ROUTE] = {
|
|
47
|
-
target: `http://localhost:${DEVTOOLS_UI_LOCAL_PORT}${DEVTOOLS_UI_ROUTE}`,
|
|
48
|
-
changeOrigin: true,
|
|
49
|
-
followRedirects: true,
|
|
50
|
-
ws: true,
|
|
51
|
-
rewrite: (path) => path.replace(DEVTOOLS_UI_ROUTE, "")
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
nuxt.hooks.hook("close", () => {
|
|
56
|
-
stopSubprocess();
|
|
57
|
-
});
|
|
58
|
-
process.on("exit", () => {
|
|
59
|
-
stopSubprocess();
|
|
60
|
-
});
|
|
61
|
-
onDevToolsInitialized(() => {
|
|
62
|
-
const rpc = extendServerRpc(
|
|
63
|
-
RPC_NAMESPACE,
|
|
64
|
-
{
|
|
65
|
-
async getSlicemachineConfig() {
|
|
66
|
-
const configPath = resolve(nuxt.options.rootDir, "slicemachine.config.json");
|
|
67
|
-
if (existsSync(configPath)) {
|
|
68
|
-
return JSON.parse(await readFile(configPath, "utf-8"));
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
},
|
|
72
|
-
isSliceMachineStarted() {
|
|
73
|
-
return subProcess !== null;
|
|
74
|
-
},
|
|
75
|
-
startSliceMachine() {
|
|
76
|
-
stopSubprocess();
|
|
77
|
-
subProcess = startSubprocess({
|
|
78
|
-
command: "npx",
|
|
79
|
-
args: ["start-slicemachine"],
|
|
80
|
-
cwd: nuxt.options.rootDir
|
|
81
|
-
}, {
|
|
82
|
-
id: "slicemachine",
|
|
83
|
-
name: "SliceMachine",
|
|
84
|
-
icon: "i-simple-icons-prismic"
|
|
85
|
-
}, nuxt);
|
|
86
|
-
rpc.broadcast.updateStatus(SliceMachineStatus.STARTED);
|
|
87
|
-
return SliceMachineStatus.STARTED;
|
|
88
|
-
},
|
|
89
|
-
stopSliceMachine() {
|
|
90
|
-
stopSubprocess();
|
|
91
|
-
rpc.broadcast.updateStatus(SliceMachineStatus.STOPPED);
|
|
92
|
-
return SliceMachineStatus.STOPPED;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
nuxt.hook("devtools:customTabs", (tabs) => {
|
|
98
|
-
tabs.push({
|
|
99
|
-
// unique identifier
|
|
100
|
-
name: "prismic",
|
|
101
|
-
// title to display in the tab
|
|
102
|
-
title: "Prismic",
|
|
103
|
-
// any icon from Iconify, or a URL to an image
|
|
104
|
-
icon: "i-simple-icons-prismic",
|
|
105
|
-
// iframe view
|
|
106
|
-
view: {
|
|
107
|
-
type: "iframe",
|
|
108
|
-
src: DEVTOOLS_UI_ROUTE
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
};
|
|
9
|
+
const name = "@nuxtjs/prismic";
|
|
10
|
+
const version = "5.0.0-canary.130d8b9";
|
|
113
11
|
|
|
114
12
|
const logger = useLogger("nuxt:prismic");
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
13
|
+
async function addPrismicClient() {
|
|
14
|
+
try {
|
|
15
|
+
const pkg = await readPackage();
|
|
16
|
+
if (!pkg.dependencies?.["@prismicio/client"] && !pkg.devDependencies?.["@prismicio/client"]) {
|
|
17
|
+
await addDependency("@prismicio/client");
|
|
18
|
+
logger.info("Added `@prismicio/client` required peer dependency");
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
121
21
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const module = defineNuxtModule({
|
|
22
|
+
}
|
|
23
|
+
const module$1 = defineNuxtModule({
|
|
127
24
|
meta: {
|
|
128
|
-
name
|
|
25
|
+
name,
|
|
26
|
+
version,
|
|
129
27
|
configKey: "prismic",
|
|
130
28
|
compatibility: { nuxt: ">=3.7.0" }
|
|
131
29
|
},
|
|
30
|
+
onInstall() {
|
|
31
|
+
return addPrismicClient();
|
|
32
|
+
},
|
|
33
|
+
onUpgrade(_options, _nuxt, previousVersion) {
|
|
34
|
+
const previousMajor = parseInt(previousVersion.split(".")[0]);
|
|
35
|
+
if (previousMajor < 4) {
|
|
36
|
+
return addPrismicClient();
|
|
37
|
+
}
|
|
38
|
+
},
|
|
132
39
|
defaults: (nuxt) => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
linkResolver: "~/prismic/linkResolver",
|
|
147
|
-
richTextSerializer: "~/prismic/richTextSerializer"
|
|
148
|
-
};
|
|
149
|
-
prismicComponentsFiles = {
|
|
150
|
-
linkRel: "~/prismic/linkRel",
|
|
151
|
-
richTextComponents: "~/prismic/richTextComponents",
|
|
152
|
-
sliceZoneDefaultComponent: "~/prismic/sliceZoneDefaultComponent"
|
|
40
|
+
const nuxt3flavor = getNuxtVersion(nuxt).startsWith("3") && !nuxt.options?.future?.compatibilityVersion;
|
|
41
|
+
if (nuxt3flavor) {
|
|
42
|
+
return {
|
|
43
|
+
endpoint: "",
|
|
44
|
+
environment: "",
|
|
45
|
+
clientConfig: {},
|
|
46
|
+
client: "~/app/prismic/client",
|
|
47
|
+
linkResolver: "~/app/prismic/linkResolver",
|
|
48
|
+
preview: "/preview",
|
|
49
|
+
toolbar: true,
|
|
50
|
+
components: {
|
|
51
|
+
richTextComponents: "~/app/prismic/richTextComponents "
|
|
52
|
+
}
|
|
153
53
|
};
|
|
154
54
|
}
|
|
155
55
|
return {
|
|
156
56
|
endpoint: "",
|
|
157
57
|
environment: "",
|
|
58
|
+
client: "~/prismic/client",
|
|
59
|
+
linkResolver: "~/prismic/linkResolver",
|
|
158
60
|
clientConfig: {},
|
|
159
|
-
...prismicFiles,
|
|
160
|
-
injectComponents: true,
|
|
161
|
-
components: prismicComponentsFiles,
|
|
162
61
|
preview: "/preview",
|
|
163
62
|
toolbar: true,
|
|
164
|
-
|
|
63
|
+
components: {
|
|
64
|
+
richTextComponents: "~/prismic/richTextComponents"
|
|
65
|
+
}
|
|
165
66
|
};
|
|
166
67
|
},
|
|
167
|
-
hooks: {},
|
|
168
68
|
setup(options, nuxt) {
|
|
169
|
-
nuxt.options.runtimeConfig.public ||= {};
|
|
170
|
-
const moduleOptions = defu(nuxt.options.runtimeConfig.public.prismic, options);
|
|
171
|
-
nuxt.options.runtimeConfig.public.prismic = moduleOptions;
|
|
172
69
|
const resolver = createResolver(import.meta.url);
|
|
173
|
-
|
|
174
|
-
|
|
70
|
+
const moduleOptions = defu(
|
|
71
|
+
nuxt.options.runtimeConfig.public?.prismic,
|
|
72
|
+
options
|
|
73
|
+
);
|
|
74
|
+
exposeRuntimeConfig();
|
|
75
|
+
transpileDependencies();
|
|
76
|
+
const ok = proxyUserFiles();
|
|
77
|
+
if (!ok) return;
|
|
78
|
+
addRuntimePlugins();
|
|
79
|
+
addAutoImports();
|
|
80
|
+
addPreviewRoute();
|
|
81
|
+
extendESLintConfig();
|
|
82
|
+
function exposeRuntimeConfig() {
|
|
83
|
+
nuxt.options.runtimeConfig.public ||= {};
|
|
84
|
+
nuxt.options.runtimeConfig.public.prismic = moduleOptions;
|
|
85
|
+
}
|
|
86
|
+
function transpileDependencies() {
|
|
87
|
+
nuxt.options.build.transpile.push(
|
|
88
|
+
resolver.resolve("runtime"),
|
|
89
|
+
"@nuxtjs/prismic",
|
|
90
|
+
"@prismicio/vue"
|
|
91
|
+
);
|
|
92
|
+
nuxt.options.vite.optimizeDeps ||= {};
|
|
93
|
+
nuxt.options.vite.optimizeDeps.exclude ||= [];
|
|
94
|
+
nuxt.options.vite.optimizeDeps.exclude.push("@prismicio/vue");
|
|
175
95
|
}
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
96
|
+
function proxyUserFiles() {
|
|
97
|
+
const proxyUserFileWithUndefinedFallback = (filename, path) => {
|
|
98
|
+
const resolvedFilename = `prismic/proxy/${filename}.ts`;
|
|
99
|
+
const resolvedPath = path.replace(/^(~~|@@)/, nuxt.options.rootDir).replace(/^(~|@)/, nuxt.options.srcDir);
|
|
100
|
+
const maybeUserFile = fileExists(resolvedPath, [
|
|
101
|
+
"js",
|
|
102
|
+
"mjs",
|
|
103
|
+
"ts",
|
|
104
|
+
"vue"
|
|
105
|
+
]);
|
|
106
|
+
if (maybeUserFile) {
|
|
107
|
+
logger.info(
|
|
108
|
+
`Using user-defined \`${filename}\` at \`${maybeUserFile.replace(nuxt.options.srcDir, "~").replace(nuxt.options.rootDir, "~~").replace(/\\/g, "/")}\``
|
|
109
|
+
);
|
|
110
|
+
addTemplate({
|
|
111
|
+
filename: resolvedFilename,
|
|
112
|
+
getContents: () => `export { default } from '${path}'`
|
|
113
|
+
});
|
|
114
|
+
return true;
|
|
115
|
+
} else {
|
|
116
|
+
addTemplate({
|
|
117
|
+
filename: resolvedFilename,
|
|
118
|
+
getContents: () => "export default undefined"
|
|
119
|
+
});
|
|
120
|
+
return false;
|
|
184
121
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
});
|
|
122
|
+
};
|
|
123
|
+
const proxiedUserClient = proxyUserFileWithUndefinedFallback(
|
|
124
|
+
"client",
|
|
125
|
+
moduleOptions.client
|
|
126
|
+
);
|
|
127
|
+
if (!moduleOptions.endpoint && !proxiedUserClient && !process.env.NUXT_PUBLIC_PRISMIC_ENDPOINT) {
|
|
128
|
+
logger.warn(
|
|
129
|
+
`\`endpoint\` option is missing and \`${moduleOptions.client}\` was not found. At least one of them is required for the module to run. Disabling module...`
|
|
130
|
+
);
|
|
195
131
|
return false;
|
|
196
132
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
133
|
+
proxyUserFileWithUndefinedFallback(
|
|
134
|
+
"linkResolver",
|
|
135
|
+
moduleOptions.linkResolver
|
|
136
|
+
);
|
|
137
|
+
proxyUserFileWithUndefinedFallback(
|
|
138
|
+
"richTextComponents",
|
|
139
|
+
moduleOptions.components.richTextComponents
|
|
140
|
+
);
|
|
141
|
+
return true;
|
|
202
142
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
nuxt.options.build.transpile.push(resolver.resolve("runtime"), "@nuxtjs/prismic", "@prismicio/vue");
|
|
209
|
-
nuxt.options.vite.optimizeDeps ||= {};
|
|
210
|
-
nuxt.options.vite.optimizeDeps.exclude ||= [];
|
|
211
|
-
nuxt.options.vite.optimizeDeps.exclude.push("@prismicio/vue");
|
|
212
|
-
addPlugin(resolver.resolve("runtime/plugin"));
|
|
213
|
-
addPlugin(resolver.resolve("runtime/plugin.client"));
|
|
214
|
-
if (moduleOptions.injectComponents) {
|
|
143
|
+
function addRuntimePlugins() {
|
|
144
|
+
addPlugin(resolver.resolve("runtime/plugin"));
|
|
145
|
+
addPlugin(resolver.resolve("runtime/plugin.client"));
|
|
146
|
+
}
|
|
147
|
+
function addAutoImports() {
|
|
215
148
|
[
|
|
216
|
-
"PrismicEmbed",
|
|
217
149
|
"PrismicImage",
|
|
218
150
|
"PrismicLink",
|
|
219
151
|
"PrismicText",
|
|
220
152
|
"PrismicRichText",
|
|
221
153
|
"PrismicTable",
|
|
222
154
|
"SliceZone"
|
|
223
|
-
].forEach((
|
|
155
|
+
].forEach((entry) => {
|
|
224
156
|
addComponent({
|
|
225
|
-
name:
|
|
226
|
-
export:
|
|
157
|
+
name: entry,
|
|
158
|
+
export: entry,
|
|
227
159
|
filePath: "@prismicio/vue"
|
|
228
160
|
});
|
|
229
161
|
});
|
|
162
|
+
addImports(
|
|
163
|
+
[
|
|
164
|
+
"usePrismic",
|
|
165
|
+
"getSliceComponentProps",
|
|
166
|
+
"defineSliceZoneComponents",
|
|
167
|
+
"getRichTextComponentProps",
|
|
168
|
+
"getTableComponentProps"
|
|
169
|
+
].map((entry) => ({ name: entry, as: entry, from: "@prismicio/vue" }))
|
|
170
|
+
);
|
|
171
|
+
addImports({
|
|
172
|
+
name: "usePrismicPreview",
|
|
173
|
+
as: "usePrismicPreview",
|
|
174
|
+
from: resolver.resolve("runtime/usePrismicPreview")
|
|
175
|
+
});
|
|
230
176
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
// Checked before
|
|
260
|
-
file: resolver.resolve("runtime/PrismicPreview.vue")
|
|
177
|
+
function addPreviewRoute() {
|
|
178
|
+
if (moduleOptions.preview) {
|
|
179
|
+
const maybeUserPreviewPage = fileExists(
|
|
180
|
+
join(
|
|
181
|
+
nuxt.options.srcDir,
|
|
182
|
+
nuxt.options.dir.pages,
|
|
183
|
+
moduleOptions.preview
|
|
184
|
+
),
|
|
185
|
+
["js", "ts", "vue"]
|
|
186
|
+
);
|
|
187
|
+
if (maybeUserPreviewPage) {
|
|
188
|
+
logger.info(
|
|
189
|
+
`Using user-defined preview page at \`${maybeUserPreviewPage.replace(join(nuxt.options.srcDir), "~").replace(nuxt.options.rootDir, "~~").replace(
|
|
190
|
+
/\\/g,
|
|
191
|
+
"/"
|
|
192
|
+
)}\`, available at \`${moduleOptions.preview}\``
|
|
193
|
+
);
|
|
194
|
+
} else {
|
|
195
|
+
logger.info(
|
|
196
|
+
`Using default preview page, available at \`${moduleOptions.preview}\``
|
|
197
|
+
);
|
|
198
|
+
extendPages((pages) => {
|
|
199
|
+
pages.unshift({
|
|
200
|
+
name: "prismic-preview",
|
|
201
|
+
path: moduleOptions.preview,
|
|
202
|
+
// Checked before
|
|
203
|
+
file: resolver.resolve("runtime/PrismicPreview.vue")
|
|
204
|
+
});
|
|
261
205
|
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
206
|
+
}
|
|
207
|
+
if (!moduleOptions.toolbar) {
|
|
208
|
+
logger.warn(
|
|
209
|
+
"`toolbar` option is disabled but `preview` is enabled. Previews won't work unless you manually load the toolbar."
|
|
210
|
+
);
|
|
211
|
+
}
|
|
266
212
|
}
|
|
267
213
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
214
|
+
function extendESLintConfig() {
|
|
215
|
+
nuxt.hook(
|
|
216
|
+
// @ts-expect-error 3rd party hook
|
|
217
|
+
"eslint:config:addons",
|
|
218
|
+
(addons) => {
|
|
219
|
+
addons.push({
|
|
220
|
+
name: "@nuxtjs/prismic",
|
|
221
|
+
async getConfigs() {
|
|
222
|
+
const configPath = resolver.resolve(
|
|
223
|
+
nuxt.options.rootDir,
|
|
224
|
+
"slicemachine.config.json"
|
|
225
|
+
);
|
|
226
|
+
const configs = [];
|
|
227
|
+
try {
|
|
228
|
+
if (existsSync(configPath)) {
|
|
229
|
+
const config = JSON.parse(await readFile(configPath, "utf-8"));
|
|
230
|
+
if (config && "libraries" in config && Array.isArray(config.libraries)) {
|
|
231
|
+
configs.push(
|
|
232
|
+
JSON.stringify({
|
|
233
|
+
files: config.libraries.map(
|
|
234
|
+
(library) => `${library.replace("./", "")}/**/index.vue`
|
|
235
|
+
),
|
|
236
|
+
rules: {
|
|
237
|
+
"vue/multi-word-component-names": "off"
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
);
|
|
282
241
|
}
|
|
283
|
-
}
|
|
242
|
+
}
|
|
243
|
+
} catch {
|
|
284
244
|
}
|
|
245
|
+
return { configs };
|
|
285
246
|
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return { configs };
|
|
247
|
+
});
|
|
289
248
|
}
|
|
290
|
-
|
|
291
|
-
}
|
|
249
|
+
);
|
|
250
|
+
}
|
|
292
251
|
}
|
|
293
252
|
});
|
|
253
|
+
function fileExists(path, extensions = ["js", "ts"]) {
|
|
254
|
+
if (!path) {
|
|
255
|
+
return null;
|
|
256
|
+
} else if (existsSync(path)) {
|
|
257
|
+
return path;
|
|
258
|
+
}
|
|
259
|
+
const extension = extensions.find(
|
|
260
|
+
(extension2) => existsSync(`${path}.${extension2}`)
|
|
261
|
+
);
|
|
262
|
+
return extension ? `${path}.${extension}` : null;
|
|
263
|
+
}
|
|
294
264
|
|
|
295
|
-
export { module as default };
|
|
265
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,27 +1,14 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { usePrismicPreview, useSeoMeta } from "#imports";
|
|
3
|
+
useSeoMeta({ title: "Prismic Preview - Loading" });
|
|
4
|
+
usePrismicPreview();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
1
7
|
<template>
|
|
2
|
-
<section
|
|
3
|
-
<figure>
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
alt="Prismic"
|
|
7
|
-
>
|
|
8
|
-
<figcaption>
|
|
9
|
-
Loading preview...
|
|
10
|
-
</figcaption>
|
|
8
|
+
<section style="position: fixed; inset: 0; display: flex; justify-content: center; align-items: center; background: #ffffff;">
|
|
9
|
+
<figure style="text-align: center;">
|
|
10
|
+
<svg style="height: 2rem;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 109 28" class="dark:text-gray-ee h-6 w-auto text-black md:h-7"><path fill="#000000" fill-rule="evenodd" d="m27.629 14.573-2.064-2.06a.869.869 0 0 1-.256-.616V9.376c0-2.33-.242-3.175-.699-4.026a4.753 4.753 0 0 0-1.98-1.976c-.853-.455-1.7-.698-4.033-.698h-3.339a.175.175 0 0 1-.123-.297l2.063-2.06a.877.877 0 0 1 .62-.256h1.16c3.112 0 4.24.323 5.378.93a6.337 6.337 0 0 1 2.64 2.635c.608 1.135.932 2.262.932 5.368v5.454a.175.175 0 0 1-.3.123ZM13.389 27.64l2.064-2.06a.876.876 0 0 1 .62-.256h2.524c2.334 0 3.18-.243 4.034-.698a4.754 4.754 0 0 0 1.979-1.976c.456-.851.7-1.696.7-4.026v-3.332a.174.174 0 0 1 .298-.123l2.064 2.06a.87.87 0 0 1 .255.616v1.159c0 3.106-.323 4.233-.932 5.368a6.338 6.338 0 0 1-2.64 2.634c-1.137.608-2.266.931-5.378.931h-5.464a.174.174 0 0 1-.124-.297ZM2.363 15.487l-2.064-2.06A.175.175 0 0 0 0 13.55v5.454c0 3.106.324 4.232.933 5.368a6.337 6.337 0 0 0 2.639 2.634c1.138.608 2.266.931 5.378.931h1.16a.877.877 0 0 0 .62-.256l2.063-2.06a.174.174 0 0 0-.124-.297H9.331c-2.334 0-3.18-.243-4.034-.698a4.753 4.753 0 0 1-1.98-1.976c-.456-.852-.699-1.696-.699-4.026v-2.522a.869.869 0 0 0-.255-.615ZM14.539.36l-2.064 2.06a.876.876 0 0 1-.62.256H9.332c-2.334 0-3.18.243-4.034.698a4.753 4.753 0 0 0-1.98 1.976c-.456.851-.699 1.696-.699 4.026v3.332a.175.175 0 0 1-.299.123L.256 10.77A.87.87 0 0 1 0 10.155V8.996C0 5.89.324 4.763.933 3.628A6.338 6.338 0 0 1 3.572.994C4.71.386 5.838.063 8.95.063h5.465a.175.175 0 0 1 .124.297Zm5.915 7.188 2.814 2.685a.175.175 0 0 0 .296-.126V7.902a3.488 3.488 0 0 0-3.491-3.484h-6.62a.877.877 0 0 0-.618.255l-2.066 2.06a.174.174 0 0 0 .124.298H19.2c.218 0 .426.04.617.112.233.084.45.22.637.405ZM17.737 23.29l2.69-2.81c.187-.186.322-.403.407-.635.072-.191.112-.399.112-.616v-8.291a.175.175 0 0 1 .299-.123l2.064 2.062a.87.87 0 0 1 .255.615V20.1a3.488 3.488 0 0 1-3.49 3.485h-2.21a.175.175 0 0 1-.127-.295ZM7.474 20.451 4.66 17.767a.175.175 0 0 0-.296.125v2.206a3.488 3.488 0 0 0 3.491 3.484h6.62a.876.876 0 0 0 .618-.256l2.066-2.06a.174.174 0 0 0-.124-.297H8.728c-.218 0-.426-.04-.618-.112a1.74 1.74 0 0 1-.636-.406Zm2.717-15.739-2.69 2.81a1.735 1.735 0 0 0-.406.635c-.073.192-.113.4-.113.616v8.292a.174.174 0 0 1-.299.122l-2.063-2.06a.87.87 0 0 1-.255-.615v-6.61a3.488 3.488 0 0 1 3.491-3.484h2.21a.175.175 0 0 1 .126.294ZM36.622 8.54h-.676c-.562 0-1.018.454-1.018 1.014v14.32c0 .561.456 1.015 1.018 1.015h.625c.563 0 1.019-.454 1.019-1.014V18.28c0-.037.03-.066.066-.066.134.184.304.373.51.565.208.193.46.374.755.543.296.17.636.308 1.02.416a4.99 4.99 0 0 0 1.332.161 4.823 4.823 0 0 0 3.716-1.685 5.737 5.737 0 0 0 1.053-1.848c.252-.708.377-1.47.377-2.286a7.17 7.17 0 0 0-.354-2.286 5.333 5.333 0 0 0-1.043-1.848 4.927 4.927 0 0 0-1.664-1.235c-.65-.3-1.383-.45-2.196-.45-.755 0-1.457.153-2.108.461-.65.308-1.168.8-1.553 1.478a.044.044 0 0 1-.044-.044V9.37a.833.833 0 0 0-.835-.831Zm6.925 4.295c.14.4.21.816.21 1.247 0 .431-.07.847-.21 1.247a3.102 3.102 0 0 1-1.608 1.801 2.988 2.988 0 0 1-1.31.277 2.985 2.985 0 0 1-2.296-1.016 3.155 3.155 0 0 1-.621-1.062c-.14-.4-.21-.816-.21-1.247 0-.431.07-.847.21-1.247a3.101 3.101 0 0 1 1.608-1.801 2.985 2.985 0 0 1 1.31-.277 2.984 2.984 0 0 1 2.295 1.016c.274.308.481.662.622 1.062Zm7.471-4.295h-.762c-.563 0-1.019.454-1.019 1.014v9.056c0 .56.456 1.014 1.019 1.014h.625c.562 0 1.018-.454 1.018-1.014v-4.92c0-.155.033-.386.1-.694.067-.307.2-.615.4-.923.2-.308.487-.581.865-.82.377-.239.876-.358 1.497-.358.207 0 .418.02.632.058a.555.555 0 0 0 .654-.545v-1.52a.59.59 0 0 0-.476-.58 2.448 2.448 0 0 0-.477-.045c-.71 0-1.339.177-1.886.53-.547.355-.969.855-1.264 1.502a.044.044 0 0 1-.045-.045v-.833a.88.88 0 0 0-.88-.877Zm8.87 0h-.625c-.563 0-1.019.454-1.019 1.014v9.056c0 .56.456 1.014 1.019 1.014h.625c.562 0 1.018-.454 1.018-1.014V9.553c0-.56-.456-1.014-1.018-1.014Zm-1.544-4.93c-.318.33-.477.719-.477 1.165 0 .447.159.836.477 1.167.318.33.721.496 1.21.496.487 0 .898-.158 1.23-.473.333-.316.5-.712.5-1.19a1.57 1.57 0 0 0-.5-1.189c-.332-.315-.743-.473-1.23-.473-.489 0-.892.165-1.21.496Zm9.55 6.87c.422 0 .903.197 1.443.593.396.29.943.257 1.301-.079l.332-.31a1.012 1.012 0 0 0-.059-1.53c-.31-.248-.59-.418-.842-.51a6.1 6.1 0 0 0-2.108-.381c-.532 0-1.057.069-1.575.207a4.093 4.093 0 0 0-1.375.647c-.4.292-.721.666-.965 1.12-.245.454-.366.99-.366 1.605 0 .708.14 1.262.421 1.663.281.4.636.712 1.065.935a5.23 5.23 0 0 0 1.386.485c.496.1.958.208 1.387.323.429.116.784.266 1.065.45.28.185.421.47.421.855a.976.976 0 0 1-.166.566c-.11.161-.255.296-.433.404-.177.108-.37.185-.576.23-.207.047-.407.07-.6.07-.561 0-1.038-.127-1.43-.381a3.795 3.795 0 0 1-.42-.328 1.022 1.022 0 0 0-1.386.037l-.276.27a1.012 1.012 0 0 0 .093 1.53c.38.29.707.484.98.58.694.247 1.456.37 2.284.37a7.46 7.46 0 0 0 1.642-.184 4.618 4.618 0 0 0 1.475-.6 3.29 3.29 0 0 0 1.065-1.098c.274-.454.41-1.012.41-1.674 0-.724-.14-1.293-.42-1.709a3.077 3.077 0 0 0-1.066-.981 5.32 5.32 0 0 0-1.386-.531 82.131 82.131 0 0 1-1.387-.335 4.536 4.536 0 0 1-1.065-.393c-.28-.154-.421-.4-.421-.739 0-.415.17-.716.51-.9a2.16 2.16 0 0 1 1.043-.277Zm7.989-1.94h-.492c-.562 0-1.018.454-1.018 1.014v9.056c0 .56.456 1.014 1.018 1.014h.625c.563 0 1.019-.454 1.019-1.014v-5.036c0-.37.044-.724.133-1.062a2.52 2.52 0 0 1 .433-.901c.2-.262.45-.47.754-.623.303-.155.676-.231 1.12-.231.651 0 1.117.204 1.398.611.281.408.421.959.421 1.652v5.59c0 .56.457 1.014 1.02 1.014h.624c.563 0 1.019-.454 1.019-1.014v-4.99c0-.354.04-.704.122-1.05a2.71 2.71 0 0 1 .399-.924 2.09 2.09 0 0 1 .71-.647c.288-.162.64-.242 1.054-.242.399 0 .724.069.976.207a1.6 1.6 0 0 1 .599.566 2.4 2.4 0 0 1 .31.832c.06.315.09.642.09.981v5.267c0 .56.455 1.014 1.018 1.014h.625c.562 0 1.018-.454 1.018-1.014v-5.59c0-.662-.066-1.282-.2-1.86a4.265 4.265 0 0 0-.654-1.512 3.172 3.172 0 0 0-1.187-1.016c-.488-.246-1.087-.37-1.797-.37-.798 0-1.486.166-2.063.497-.577.331-1.057.85-1.442 1.559-.547-1.37-1.656-2.055-3.328-2.055-.887 0-1.593.204-2.118.611a4.342 4.342 0 0 0-1.187 1.398v-.718c0-.56-.456-1.014-1.019-1.014Zm19.922 0h-.625c-.562 0-1.018.454-1.018 1.014v9.056c0 .56.456 1.014 1.018 1.014h.625c.563 0 1.019-.454 1.019-1.014V9.553c0-.56-.456-1.014-1.019-1.014Zm-1.543-4.93c-.318.33-.477.719-.477 1.165 0 .447.159.836.477 1.167.318.33.72.496 1.209.496.488 0 .898-.158 1.23-.473.334-.316.5-.712.5-1.19a1.57 1.57 0 0 0-.5-1.189c-.332-.315-.742-.473-1.23-.473-.489 0-.891.165-1.21.496Zm12.257 7.447a2.9 2.9 0 0 1 .289.201 1.02 1.02 0 0 0 1.364-.097l.411-.429a1.012 1.012 0 0 0-.127-1.515c-.356-.264-.666-.448-.928-.55a5.591 5.591 0 0 0-2.052-.404c-.799 0-1.553.138-2.263.415-.71.277-1.323.67-1.841 1.178a5.588 5.588 0 0 0-1.231 1.836c-.303.716-.455 1.512-.455 2.39 0 .878.151 1.674.455 2.39a5.585 5.585 0 0 0 1.231 1.836c.518.508 1.131.9 1.841 1.178.71.277 1.464.415 2.263.415.237 0 .518-.027.843-.08a6.222 6.222 0 0 0 2.074-.75.964.964 0 0 0 .24-1.479l-.405-.453a1.022 1.022 0 0 0-1.365-.143c-.084.061-.161.11-.233.146a2.55 2.55 0 0 1-1.154.265c-.488 0-.924-.092-1.309-.277a3.11 3.11 0 0 1-1.608-1.801 3.724 3.724 0 0 1-.211-1.247c0-.431.07-.847.211-1.247a3.11 3.11 0 0 1 1.608-1.801 2.987 2.987 0 0 1 1.309-.277c.355 0 .703.1 1.043.3Z" clip-rule="evenodd"></path></svg>
|
|
11
|
+
<figcaption style="font-family: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 1rem; margin-top: .5rem;">Loading preview...</figcaption>
|
|
11
12
|
</figure>
|
|
12
13
|
</section>
|
|
13
14
|
</template>
|
|
14
|
-
|
|
15
|
-
<script setup>
|
|
16
|
-
import { useHead, usePrismicPreview } from '#imports'
|
|
17
|
-
|
|
18
|
-
useHead({
|
|
19
|
-
title: 'Prismic Preview - Loading',
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
usePrismicPreview()
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<style scoped>
|
|
26
|
-
.prismic-preview{align-items:center;background:#fff;color:#666;display:flex;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;font-size:1rem;height:100vh;justify-content:center;left:0;position:fixed;text-align:center;top:0;width:100%}img{margin-bottom:1.25rem}
|
|
27
|
-
</style>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { defineNuxtPlugin } from "#app";
|
|
2
2
|
import { refreshNuxtData, useRuntimeConfig } from "#imports";
|
|
3
|
-
export default defineNuxtPlugin(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export default defineNuxtPlugin({
|
|
4
|
+
name: "prismic:plugin:client",
|
|
5
|
+
parallel: true,
|
|
6
|
+
setup() {
|
|
7
|
+
if (useRuntimeConfig().public.prismic?.preview) {
|
|
8
|
+
window.addEventListener("prismicPreviewUpdate", (event) => {
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
refreshNuxtData();
|
|
11
|
+
});
|
|
12
|
+
}
|
|
10
13
|
}
|
|
11
14
|
});
|