@nuxtjs/prismic 3.1.0 → 3.1.1
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/README.md +15 -6
- package/dist/module.json +2 -2
- package/dist/module.mjs +4 -5
- package/dist/runtime/plugin.mjs +7 -3
- package/dist/types.d.mts +3 -2
- package/dist/types.d.ts +3 -2
- package/package.json +9 -9
- package/src/module.ts +1 -1
- package/src/runtime/plugin.ts +8 -4
package/README.md
CHANGED
|
@@ -19,17 +19,27 @@ Replace all on all files (README.md, CONTRIBUTING.md, bug_report.md, package.jso
|
|
|
19
19
|
|
|
20
20
|
Easily connect your Nuxt.js application to your content hosted on [Prismic][prismic].
|
|
21
21
|
|
|
22
|
+
- [✨ Release Notes][changelog]
|
|
23
|
+
- [🏀 Online Playground][playground]
|
|
24
|
+
- [📖 Module Documentation][nuxt-docs]
|
|
25
|
+
- [📚 Prismic Documentation][prismic-docs]
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
<!-- Highlight some of the features your module provide here -->
|
|
22
30
|
- 🚀 Add Prismic to your Nuxt app in seconds;
|
|
23
31
|
- 🎣 Access Prismic SDK through composition and options API;
|
|
24
32
|
- 🖼 Prismic previews supported.
|
|
25
33
|
|
|
26
|
-
##
|
|
34
|
+
## Quick Setup
|
|
35
|
+
|
|
36
|
+
Install the module to your Nuxt application with one command:
|
|
27
37
|
|
|
28
38
|
```bash
|
|
29
|
-
|
|
39
|
+
npx nuxi module add prismic
|
|
30
40
|
```
|
|
31
41
|
|
|
32
|
-
Then,
|
|
42
|
+
Then, configure your Prismic API endpoint:
|
|
33
43
|
|
|
34
44
|
```javascript
|
|
35
45
|
import { defineNuxtConfig } from 'nuxt'
|
|
@@ -42,9 +52,7 @@ export default defineNuxtConfig({
|
|
|
42
52
|
});
|
|
43
53
|
```
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
To discover what's new on this package check out [the changelog][changelog]. For full documentation, visit the [module documentation][nuxt-docs] and [Prismic official documentation][prismic-docs].
|
|
55
|
+
That's it! You can now use Prismic in your Nuxt app ✨
|
|
48
56
|
|
|
49
57
|
## Contributing
|
|
50
58
|
|
|
@@ -68,6 +76,7 @@ Whether you're helping us fix bugs, improve the docs, or spread the word, we'd l
|
|
|
68
76
|
|
|
69
77
|
<!-- TODO: Replace link with a more useful one if available -->
|
|
70
78
|
|
|
79
|
+
[playground]: https://stackblitz.com/github/nuxt-modules/prismic/tree/master/examples/minimal?file=pages%2Findex.vue
|
|
71
80
|
[nuxt-docs]: https://prismic.nuxtjs.org
|
|
72
81
|
[prismic-docs]: https://prismic.io/docs/technical-reference/prismicio-vue?version=v4
|
|
73
82
|
[changelog]: ./CHANGELOG.md
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -21,7 +21,7 @@ const module = defineNuxtModule({
|
|
|
21
21
|
meta: {
|
|
22
22
|
name: "@nuxtjs/prismic",
|
|
23
23
|
configKey: "prismic",
|
|
24
|
-
compatibility: { nuxt: "^3.
|
|
24
|
+
compatibility: { nuxt: "^3.7.0" }
|
|
25
25
|
},
|
|
26
26
|
defaults: (nuxt) => ({
|
|
27
27
|
endpoint: "",
|
|
@@ -37,8 +37,7 @@ const module = defineNuxtModule({
|
|
|
37
37
|
}),
|
|
38
38
|
hooks: {},
|
|
39
39
|
setup(options, nuxt) {
|
|
40
|
-
|
|
41
|
-
(_a = nuxt.options.runtimeConfig).public || (_a.public = {});
|
|
40
|
+
nuxt.options.runtimeConfig.public ||= {};
|
|
42
41
|
const moduleOptions = defu(nuxt.options.runtimeConfig.public.prismic, options);
|
|
43
42
|
nuxt.options.runtimeConfig.public.prismic = moduleOptions;
|
|
44
43
|
const proxyUserFileWithUndefinedFallback = (filename, path, extensions = ["js", "mjs", "ts"]) => {
|
|
@@ -69,8 +68,8 @@ const module = defineNuxtModule({
|
|
|
69
68
|
proxyUserFileWithUndefinedFallback("richTextSerializer", moduleOptions.richTextSerializer);
|
|
70
69
|
const resolver = createResolver(import.meta.url);
|
|
71
70
|
nuxt.options.build.transpile.push(resolver.resolve("runtime"), "@nuxtjs/prismic", "@prismicio/vue");
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
nuxt.options.vite.optimizeDeps ||= {};
|
|
72
|
+
nuxt.options.vite.optimizeDeps.exclude ||= [];
|
|
74
73
|
nuxt.options.vite.optimizeDeps.exclude.push("@prismicio/vue");
|
|
75
74
|
addPlugin(resolver.resolve("runtime/plugin"));
|
|
76
75
|
addPlugin(resolver.resolve("runtime/plugin.client"));
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -25,8 +25,11 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
25
25
|
nuxtApp.vueApp.use(prismicPlugin);
|
|
26
26
|
if (options.preview) {
|
|
27
27
|
const previewCookie = useCookie("io.prismic.preview").value;
|
|
28
|
-
if (
|
|
29
|
-
|
|
28
|
+
if (import.meta.server) {
|
|
29
|
+
const req = useRequestEvent()?.node.req;
|
|
30
|
+
if (req) {
|
|
31
|
+
prismicPlugin.client.enableAutoPreviewsFromReq(req);
|
|
32
|
+
}
|
|
30
33
|
}
|
|
31
34
|
if (previewCookie) {
|
|
32
35
|
try {
|
|
@@ -55,7 +58,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
55
58
|
key: "prismic-preview",
|
|
56
59
|
src: `https://static.cdn.prismic.io/prismic.min.js?repo=${repositoryName}&new=true`,
|
|
57
60
|
async: true,
|
|
58
|
-
defer: true
|
|
61
|
+
defer: true,
|
|
62
|
+
crossorigin: "anonymous"
|
|
59
63
|
}]
|
|
60
64
|
});
|
|
61
65
|
} else {
|
package/dist/types.d.mts
CHANGED
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/prismic",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Easily connect your Nuxt 3 application to your content hosted on Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -50,22 +50,22 @@
|
|
|
50
50
|
"unit:watch": "vitest watch"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@nuxt/kit": "^3.
|
|
53
|
+
"@nuxt/kit": "^3.11.1",
|
|
54
54
|
"@prismicio/client": "^7.3.1",
|
|
55
55
|
"@prismicio/vue": "^4.1.0",
|
|
56
56
|
"consola": "^3.2.3",
|
|
57
|
-
"defu": "^6.1.
|
|
57
|
+
"defu": "^6.1.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@nuxt/module-builder": "^0.5.
|
|
60
|
+
"@nuxt/module-builder": "^0.5.5",
|
|
61
61
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
62
|
-
"@vitest/coverage-v8": "^
|
|
63
|
-
"eslint": "^8.
|
|
62
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
63
|
+
"eslint": "^8.57.0",
|
|
64
64
|
"mock-fs": "^5.2.0",
|
|
65
|
-
"nuxt": "^3.
|
|
65
|
+
"nuxt": "^3.11.1",
|
|
66
66
|
"standard-version": "^9.5.0",
|
|
67
|
-
"typescript": "^5.
|
|
68
|
-
"vitest": "^
|
|
67
|
+
"typescript": "^5.4.3",
|
|
68
|
+
"vitest": "^1.4.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=16.10.0"
|
package/src/module.ts
CHANGED
package/src/runtime/plugin.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isRepositoryEndpoint, getRepositoryName, type Client } from '@prismicio/client'
|
|
2
2
|
import { createPrismic } from '@prismicio/vue'
|
|
3
3
|
|
|
4
|
-
import type { PrismicModuleOptions } from '../types'
|
|
5
4
|
import NuxtLink from '#app/components/nuxt-link'
|
|
5
|
+
import type { PrismicModuleOptions } from '../types'
|
|
6
6
|
import { defineNuxtPlugin, useCookie, useRequestEvent, onNuxtReady, refreshNuxtData, useHead, useRuntimeConfig, useRouter } from '#imports'
|
|
7
7
|
|
|
8
8
|
// @ts-expect-error vfs cannot be resolved here
|
|
@@ -36,8 +36,11 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
36
36
|
const previewCookie = useCookie('io.prismic.preview').value
|
|
37
37
|
|
|
38
38
|
// Update client with req when running server side
|
|
39
|
-
if (
|
|
40
|
-
|
|
39
|
+
if (import.meta.server) {
|
|
40
|
+
const req = useRequestEvent()?.node.req
|
|
41
|
+
if (req) {
|
|
42
|
+
prismicPlugin.client.enableAutoPreviewsFromReq(req)
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
if (previewCookie) {
|
|
@@ -80,7 +83,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
80
83
|
key: 'prismic-preview',
|
|
81
84
|
src: `https://static.cdn.prismic.io/prismic.min.js?repo=${repositoryName}&new=true`,
|
|
82
85
|
async: true,
|
|
83
|
-
defer: true
|
|
86
|
+
defer: true,
|
|
87
|
+
crossorigin: 'anonymous'
|
|
84
88
|
}]
|
|
85
89
|
})
|
|
86
90
|
} else {
|