@nuxtjs/prismic 4.1.0-pr.235.3e7479b → 4.1.0-pr.235.65ebe70
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/dist/module.d.mts +9 -9
- package/dist/module.json +1 -1
- package/dist/module.mjs +38 -13
- package/dist/runtime/PrismicPreview.vue +4 -11
- package/dist/runtime/plugin.client.js +5 -8
- package/dist/runtime/plugin.js +7 -7
- package/dist/runtime/usePrismicPreview.js +2 -2
- package/package.json +4 -2
- package/src/module.ts +54 -23
- package/src/runtime/PrismicPreview.vue +4 -31
- package/src/runtime/plugin.client.ts +5 -9
- package/src/runtime/plugin.ts +8 -8
- package/src/runtime/usePrismicPreview.ts +2 -2
package/LICENSE
CHANGED
package/dist/module.d.mts
CHANGED
|
@@ -53,6 +53,13 @@ type PrismicModuleOptions = {
|
|
|
53
53
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client}
|
|
54
54
|
*/
|
|
55
55
|
client?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The path to a file exporting a default link resolver used to resolve links
|
|
58
|
+
* when route resolvers cannot be used.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link https://prismic.io/docs/routes}
|
|
61
|
+
*/
|
|
62
|
+
linkResolver?: string;
|
|
56
63
|
/**
|
|
57
64
|
* Desired path of the preview page used by Prismic to enter preview session.
|
|
58
65
|
*
|
|
@@ -72,14 +79,7 @@ type PrismicModuleOptions = {
|
|
|
72
79
|
*/
|
|
73
80
|
toolbar?: boolean;
|
|
74
81
|
/** Options used by Prismic Vue components. */
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The path to a file exporting a default link resolver function used to
|
|
78
|
-
* resolve links.
|
|
79
|
-
*
|
|
80
|
-
* @see {@link https://prismic.io/docs/routes}
|
|
81
|
-
*/
|
|
82
|
-
linkResolver?: string;
|
|
82
|
+
components?: {
|
|
83
83
|
/**
|
|
84
84
|
* The path to a file exporting default components or shorthand definitions
|
|
85
85
|
* for rich text and table components.
|
|
@@ -87,7 +87,7 @@ type PrismicModuleOptions = {
|
|
|
87
87
|
* @see {@link https://prismic.io/docs/fields/rich-text}
|
|
88
88
|
* @see {@link https://prismic.io/docs/fields/table}
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
richTextComponents?: string;
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
/**
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,28 +1,54 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { defineNuxtModule, createResolver,
|
|
4
|
+
import { useLogger, defineNuxtModule, createResolver, addPlugin, addComponent, addImports, extendPages, getNuxtVersion, addTemplate } from '@nuxt/kit';
|
|
5
5
|
import { defu } from 'defu';
|
|
6
|
+
import { addDependency } from 'nypm';
|
|
7
|
+
import { readPackage } from 'pkg-types';
|
|
6
8
|
|
|
9
|
+
const name = "@nuxtjs/prismic";
|
|
10
|
+
const version = "4.1.0-pr.235.65ebe70";
|
|
11
|
+
|
|
12
|
+
const logger = useLogger("nuxt:prismic");
|
|
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 {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
7
23
|
const module$1 = defineNuxtModule({
|
|
8
24
|
meta: {
|
|
9
|
-
name
|
|
25
|
+
name,
|
|
26
|
+
version,
|
|
10
27
|
configKey: "prismic",
|
|
11
28
|
compatibility: { nuxt: ">=3.7.0" }
|
|
12
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
|
+
},
|
|
13
39
|
defaults: (nuxt) => {
|
|
14
40
|
const nuxt3flavor = getNuxtVersion(nuxt).startsWith("3") && !nuxt.options?.future?.compatibilityVersion;
|
|
15
41
|
if (nuxt3flavor) {
|
|
16
42
|
return {
|
|
17
|
-
endpoint: "
|
|
43
|
+
endpoint: "",
|
|
18
44
|
environment: "",
|
|
19
45
|
clientConfig: {},
|
|
20
46
|
client: "~/app/prismic/client",
|
|
47
|
+
linkResolver: "~/app/prismic/linkResolver",
|
|
21
48
|
preview: "/preview",
|
|
22
49
|
toolbar: true,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
defaultComponents: "~/app/prismic/defaultComponents"
|
|
50
|
+
components: {
|
|
51
|
+
richTextComponents: "~/app/prismic/richTextComponents "
|
|
26
52
|
}
|
|
27
53
|
};
|
|
28
54
|
}
|
|
@@ -30,18 +56,17 @@ const module$1 = defineNuxtModule({
|
|
|
30
56
|
endpoint: "",
|
|
31
57
|
environment: "",
|
|
32
58
|
client: "~/prismic/client",
|
|
59
|
+
linkResolver: "~/prismic/linkResolver",
|
|
33
60
|
clientConfig: {},
|
|
34
61
|
preview: "/preview",
|
|
35
62
|
toolbar: true,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
defaultComponents: "~/prismic/defaultComponents"
|
|
63
|
+
components: {
|
|
64
|
+
richTextComponents: "~/prismic/richTextComponents"
|
|
39
65
|
}
|
|
40
66
|
};
|
|
41
67
|
},
|
|
42
68
|
setup(options, nuxt) {
|
|
43
69
|
const resolver = createResolver(import.meta.url);
|
|
44
|
-
const logger = useLogger("nuxt:prismic");
|
|
45
70
|
const moduleOptions = defu(
|
|
46
71
|
nuxt.options.runtimeConfig.public?.prismic,
|
|
47
72
|
options
|
|
@@ -107,11 +132,11 @@ const module$1 = defineNuxtModule({
|
|
|
107
132
|
}
|
|
108
133
|
proxyUserFileWithUndefinedFallback(
|
|
109
134
|
"linkResolver",
|
|
110
|
-
moduleOptions.
|
|
135
|
+
moduleOptions.linkResolver
|
|
111
136
|
);
|
|
112
137
|
proxyUserFileWithUndefinedFallback(
|
|
113
|
-
"
|
|
114
|
-
moduleOptions.
|
|
138
|
+
"richTextComponents",
|
|
139
|
+
moduleOptions.components.richTextComponents
|
|
115
140
|
);
|
|
116
141
|
return true;
|
|
117
142
|
}
|
|
@@ -5,17 +5,10 @@ usePrismicPreview();
|
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<template>
|
|
8
|
-
<section
|
|
9
|
-
<figure>
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
alt="Prismic"
|
|
13
|
-
/>
|
|
14
|
-
<figcaption>Loading preview...</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>
|
|
15
12
|
</figure>
|
|
16
13
|
</section>
|
|
17
14
|
</template>
|
|
18
|
-
|
|
19
|
-
<style scoped>
|
|
20
|
-
.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}
|
|
21
|
-
</style>
|
|
@@ -4,14 +4,11 @@ export default defineNuxtPlugin({
|
|
|
4
4
|
name: "prismic:plugin:client",
|
|
5
5
|
parallel: true,
|
|
6
6
|
setup() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
refreshNuxtData();
|
|
13
|
-
});
|
|
14
|
-
}
|
|
7
|
+
if (useRuntimeConfig().public.prismic?.preview) {
|
|
8
|
+
window.addEventListener("prismicPreviewUpdate", (event) => {
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
refreshNuxtData();
|
|
11
|
+
});
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
14
|
});
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineNuxtPlugin } from "#app";
|
|
2
2
|
import NuxtLink from "#app/components/nuxt-link";
|
|
3
3
|
import _client from "#build/prismic/proxy/client";
|
|
4
|
-
import defaultComponents from "#build/prismic/proxy/defaultComponents";
|
|
5
4
|
import linkResolver from "#build/prismic/proxy/linkResolver";
|
|
5
|
+
import richTextComponents from "#build/prismic/proxy/richTextComponents";
|
|
6
6
|
import {
|
|
7
7
|
onNuxtReady,
|
|
8
8
|
refreshNuxtData,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
useRouter,
|
|
13
13
|
useRuntimeConfig
|
|
14
14
|
} from "#imports";
|
|
15
|
-
import { Client, createClient } from "@prismicio/client";
|
|
15
|
+
import { Client, cookie, createClient, getToolbarSrc } from "@prismicio/client";
|
|
16
16
|
import { createPrismic } from "@prismicio/vue";
|
|
17
17
|
export default defineNuxtPlugin({
|
|
18
18
|
name: "prismic:setup",
|
|
@@ -85,7 +85,7 @@ export default defineNuxtPlugin({
|
|
|
85
85
|
script: [
|
|
86
86
|
{
|
|
87
87
|
key: "prismic-preview",
|
|
88
|
-
src:
|
|
88
|
+
src: getToolbarSrc(client.repositoryName),
|
|
89
89
|
async: true,
|
|
90
90
|
defer: true,
|
|
91
91
|
crossorigin: "anonymous"
|
|
@@ -93,16 +93,16 @@ export default defineNuxtPlugin({
|
|
|
93
93
|
]
|
|
94
94
|
});
|
|
95
95
|
} else {
|
|
96
|
-
useCookie(
|
|
96
|
+
useCookie(cookie.preview).value = null;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
const prismicPlugin = createPrismic({
|
|
100
100
|
client,
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
linkResolver,
|
|
102
|
+
components: {
|
|
103
103
|
linkInternalComponent: NuxtLink,
|
|
104
104
|
linkExternalComponent: NuxtLink,
|
|
105
|
-
|
|
105
|
+
richTextComponents
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
nuxtApp.vueApp.use(prismicPlugin);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { usePrismic, useRouter } from "#imports";
|
|
2
2
|
import { onMounted } from "vue";
|
|
3
3
|
export const usePrismicPreview = (defaultURL = "/") => {
|
|
4
|
-
const { client,
|
|
4
|
+
const { client, linkResolver } = usePrismic();
|
|
5
5
|
const { push } = useRouter();
|
|
6
6
|
onMounted(async () => {
|
|
7
7
|
const redirectURL = await client.resolvePreviewURL({
|
|
8
|
-
linkResolver
|
|
8
|
+
linkResolver,
|
|
9
9
|
defaultURL
|
|
10
10
|
});
|
|
11
11
|
push(redirectURL);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/prismic",
|
|
3
|
-
"version": "4.1.0-pr.235.
|
|
3
|
+
"version": "4.1.0-pr.235.65ebe70",
|
|
4
4
|
"description": "Easily connect your Nuxt application to your content hosted on Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@nuxt/kit": "^4.2.2",
|
|
56
56
|
"@prismicio/vue": "pr-89",
|
|
57
|
-
"defu": "^6.1.4"
|
|
57
|
+
"defu": "^6.1.4",
|
|
58
|
+
"nypm": "^0.6.2",
|
|
59
|
+
"pkg-types": "^2.3.0"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
62
|
"@nuxt/module-builder": "^1.0.2",
|
package/src/module.ts
CHANGED
|
@@ -15,6 +15,10 @@ import {
|
|
|
15
15
|
} from "@nuxt/kit"
|
|
16
16
|
import type { ClientConfig } from "@prismicio/client"
|
|
17
17
|
import { defu } from "defu"
|
|
18
|
+
import { addDependency } from "nypm"
|
|
19
|
+
import { readPackage } from "pkg-types"
|
|
20
|
+
|
|
21
|
+
import { name, version } from "../package.json"
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Prismic Nuxt module options.
|
|
@@ -72,6 +76,14 @@ export type PrismicModuleOptions = {
|
|
|
72
76
|
*/
|
|
73
77
|
client?: string
|
|
74
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The path to a file exporting a default link resolver used to resolve links
|
|
81
|
+
* when route resolvers cannot be used.
|
|
82
|
+
*
|
|
83
|
+
* @see {@link https://prismic.io/docs/routes}
|
|
84
|
+
*/
|
|
85
|
+
linkResolver?: string
|
|
86
|
+
|
|
75
87
|
/**
|
|
76
88
|
* Desired path of the preview page used by Prismic to enter preview session.
|
|
77
89
|
*
|
|
@@ -93,15 +105,7 @@ export type PrismicModuleOptions = {
|
|
|
93
105
|
toolbar?: boolean
|
|
94
106
|
|
|
95
107
|
/** Options used by Prismic Vue components. */
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The path to a file exporting a default link resolver function used to
|
|
99
|
-
* resolve links.
|
|
100
|
-
*
|
|
101
|
-
* @see {@link https://prismic.io/docs/routes}
|
|
102
|
-
*/
|
|
103
|
-
linkResolver?: string
|
|
104
|
-
|
|
108
|
+
components?: {
|
|
105
109
|
/**
|
|
106
110
|
* The path to a file exporting default components or shorthand definitions
|
|
107
111
|
* for rich text and table components.
|
|
@@ -109,7 +113,7 @@ export type PrismicModuleOptions = {
|
|
|
109
113
|
* @see {@link https://prismic.io/docs/fields/rich-text}
|
|
110
114
|
* @see {@link https://prismic.io/docs/fields/table}
|
|
111
115
|
*/
|
|
112
|
-
|
|
116
|
+
richTextComponents?: string
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
|
|
@@ -128,28 +132,56 @@ declare module "@nuxt/schema" {
|
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
const logger = useLogger("nuxt:prismic")
|
|
136
|
+
|
|
137
|
+
async function addPrismicClient() {
|
|
138
|
+
try {
|
|
139
|
+
const pkg = await readPackage()
|
|
140
|
+
|
|
141
|
+
if (
|
|
142
|
+
!pkg.dependencies?.["@prismicio/client"] &&
|
|
143
|
+
!pkg.devDependencies?.["@prismicio/client"]
|
|
144
|
+
) {
|
|
145
|
+
await addDependency("@prismicio/client")
|
|
146
|
+
logger.info("Added `@prismicio/client` required peer dependency")
|
|
147
|
+
}
|
|
148
|
+
} catch {
|
|
149
|
+
// noop
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
131
153
|
export default defineNuxtModule<PrismicModuleOptions>({
|
|
132
154
|
meta: {
|
|
133
|
-
name
|
|
155
|
+
name,
|
|
156
|
+
version,
|
|
134
157
|
configKey: "prismic",
|
|
135
158
|
compatibility: { nuxt: ">=3.7.0" },
|
|
136
159
|
},
|
|
137
|
-
|
|
160
|
+
onInstall() {
|
|
161
|
+
return addPrismicClient()
|
|
162
|
+
},
|
|
163
|
+
onUpgrade(_options: unknown, _nuxt: unknown, previousVersion: string) {
|
|
164
|
+
const previousMajor = parseInt(previousVersion.split(".")[0]!)
|
|
165
|
+
if (previousMajor < 4) {
|
|
166
|
+
return addPrismicClient()
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
defaults: (nuxt): Required<PrismicModuleOptions> => {
|
|
138
170
|
const nuxt3flavor =
|
|
139
171
|
getNuxtVersion(nuxt).startsWith("3") &&
|
|
140
172
|
!nuxt.options?.future?.compatibilityVersion
|
|
141
173
|
|
|
142
174
|
if (nuxt3flavor) {
|
|
143
175
|
return {
|
|
144
|
-
endpoint: "
|
|
176
|
+
endpoint: "",
|
|
145
177
|
environment: "",
|
|
146
178
|
clientConfig: {},
|
|
147
179
|
client: "~/app/prismic/client",
|
|
180
|
+
linkResolver: "~/app/prismic/linkResolver",
|
|
148
181
|
preview: "/preview",
|
|
149
182
|
toolbar: true,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
defaultComponents: "~/app/prismic/defaultComponents",
|
|
183
|
+
components: {
|
|
184
|
+
richTextComponents: "~/app/prismic/richTextComponents ",
|
|
153
185
|
},
|
|
154
186
|
}
|
|
155
187
|
}
|
|
@@ -158,18 +190,17 @@ export default defineNuxtModule<PrismicModuleOptions>({
|
|
|
158
190
|
endpoint: "",
|
|
159
191
|
environment: "",
|
|
160
192
|
client: "~/prismic/client",
|
|
193
|
+
linkResolver: "~/prismic/linkResolver",
|
|
161
194
|
clientConfig: {},
|
|
162
195
|
preview: "/preview",
|
|
163
196
|
toolbar: true,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
defaultComponents: "~/prismic/defaultComponents",
|
|
197
|
+
components: {
|
|
198
|
+
richTextComponents: "~/prismic/richTextComponents",
|
|
167
199
|
},
|
|
168
200
|
}
|
|
169
201
|
},
|
|
170
202
|
setup(options, nuxt) {
|
|
171
203
|
const resolver = createResolver(import.meta.url)
|
|
172
|
-
const logger = useLogger("nuxt:prismic")
|
|
173
204
|
|
|
174
205
|
const moduleOptions: PrismicModuleOptions = defu(
|
|
175
206
|
nuxt.options.runtimeConfig.public?.prismic,
|
|
@@ -257,11 +288,11 @@ export default defineNuxtModule<PrismicModuleOptions>({
|
|
|
257
288
|
}
|
|
258
289
|
proxyUserFileWithUndefinedFallback(
|
|
259
290
|
"linkResolver",
|
|
260
|
-
moduleOptions.
|
|
291
|
+
moduleOptions.linkResolver!,
|
|
261
292
|
)
|
|
262
293
|
proxyUserFileWithUndefinedFallback(
|
|
263
|
-
"
|
|
264
|
-
moduleOptions.
|
|
294
|
+
"richTextComponents",
|
|
295
|
+
moduleOptions.components!.richTextComponents!,
|
|
265
296
|
)
|
|
266
297
|
|
|
267
298
|
return true
|
|
@@ -6,37 +6,10 @@ usePrismicPreview()
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<template>
|
|
9
|
-
<section
|
|
10
|
-
<figure>
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
alt="Prismic"
|
|
14
|
-
/>
|
|
15
|
-
<figcaption>Loading preview...</figcaption>
|
|
9
|
+
<section style="position: fixed; inset: 0; display: flex; justify-content: center; align-items: center; background: #ffffff;">
|
|
10
|
+
<figure style="text-align: center;">
|
|
11
|
+
<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>
|
|
12
|
+
<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>
|
|
16
13
|
</figure>
|
|
17
14
|
</section>
|
|
18
15
|
</template>
|
|
19
|
-
|
|
20
|
-
<style scoped>
|
|
21
|
-
.prismic-preview {
|
|
22
|
-
width: 100%;
|
|
23
|
-
height: 100vh;
|
|
24
|
-
position: fixed;
|
|
25
|
-
top: 0;
|
|
26
|
-
left: 0;
|
|
27
|
-
display: flex;
|
|
28
|
-
justify-content: center;
|
|
29
|
-
align-items: center;
|
|
30
|
-
background: #ffffff;
|
|
31
|
-
color: #666666;
|
|
32
|
-
font-family:
|
|
33
|
-
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
|
34
|
-
Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
|
35
|
-
font-size: 1rem;
|
|
36
|
-
text-align: center;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
img {
|
|
40
|
-
margin-bottom: 1.25rem;
|
|
41
|
-
}
|
|
42
|
-
</style>
|
|
@@ -5,15 +5,11 @@ export default defineNuxtPlugin({
|
|
|
5
5
|
name: "prismic:plugin:client",
|
|
6
6
|
parallel: true,
|
|
7
7
|
setup() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
event.preventDefault()
|
|
14
|
-
refreshNuxtData()
|
|
15
|
-
})
|
|
16
|
-
}
|
|
8
|
+
if (useRuntimeConfig().public.prismic?.preview) {
|
|
9
|
+
window.addEventListener("prismicPreviewUpdate", (event) => {
|
|
10
|
+
event.preventDefault()
|
|
11
|
+
refreshNuxtData()
|
|
12
|
+
})
|
|
17
13
|
}
|
|
18
14
|
},
|
|
19
15
|
})
|
package/src/runtime/plugin.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { defineNuxtPlugin } from "#app"
|
|
|
2
2
|
import NuxtLink from "#app/components/nuxt-link"
|
|
3
3
|
import _client from "#build/prismic/proxy/client"
|
|
4
4
|
// @ts-expect-error - Proxy file
|
|
5
|
-
import defaultComponents from "#build/prismic/proxy/defaultComponents"
|
|
6
|
-
// @ts-expect-error - Proxy file
|
|
7
5
|
import linkResolver from "#build/prismic/proxy/linkResolver"
|
|
6
|
+
// @ts-expect-error - Proxy file
|
|
7
|
+
import richTextComponents from "#build/prismic/proxy/richTextComponents"
|
|
8
8
|
import {
|
|
9
9
|
onNuxtReady,
|
|
10
10
|
refreshNuxtData,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
useRouter,
|
|
15
15
|
useRuntimeConfig,
|
|
16
16
|
} from "#imports"
|
|
17
|
-
import { Client, createClient } from "@prismicio/client"
|
|
17
|
+
import { Client, cookie, createClient, getToolbarSrc } from "@prismicio/client"
|
|
18
18
|
import { createPrismic } from "@prismicio/vue"
|
|
19
19
|
|
|
20
20
|
export default defineNuxtPlugin({
|
|
@@ -109,7 +109,7 @@ export default defineNuxtPlugin({
|
|
|
109
109
|
script: [
|
|
110
110
|
{
|
|
111
111
|
key: "prismic-preview",
|
|
112
|
-
src:
|
|
112
|
+
src: getToolbarSrc(client.repositoryName),
|
|
113
113
|
async: true,
|
|
114
114
|
defer: true,
|
|
115
115
|
crossorigin: "anonymous",
|
|
@@ -118,17 +118,17 @@ export default defineNuxtPlugin({
|
|
|
118
118
|
})
|
|
119
119
|
} else {
|
|
120
120
|
// TODO: We might want to let user disable this behavior because it might have unexpected side effects
|
|
121
|
-
useCookie(
|
|
121
|
+
useCookie(cookie.preview).value = null
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
const prismicPlugin = createPrismic({
|
|
126
126
|
client,
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
linkResolver,
|
|
128
|
+
components: {
|
|
129
129
|
linkInternalComponent: NuxtLink,
|
|
130
130
|
linkExternalComponent: NuxtLink,
|
|
131
|
-
|
|
131
|
+
richTextComponents,
|
|
132
132
|
},
|
|
133
133
|
})
|
|
134
134
|
|
|
@@ -4,11 +4,11 @@ import { onMounted } from "vue"
|
|
|
4
4
|
|
|
5
5
|
/** Resolves Prismic previews on the preview entry page (`/preview`) */
|
|
6
6
|
export const usePrismicPreview = (defaultURL = "/"): void => {
|
|
7
|
-
const { client,
|
|
7
|
+
const { client, linkResolver } = usePrismic()
|
|
8
8
|
const { push } = useRouter()
|
|
9
9
|
onMounted(async () => {
|
|
10
10
|
const redirectURL = await client.resolvePreviewURL({
|
|
11
|
-
linkResolver
|
|
11
|
+
linkResolver,
|
|
12
12
|
defaultURL,
|
|
13
13
|
})
|
|
14
14
|
|