@nuxtjs/prismic 1.3.2 → 1.4.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/package.json +2 -2
- package/src/module.js +2 -0
- package/templates/plugins/prismic.js +13 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/prismic",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Easily connect your Nuxt.js application to your content hosted on Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@prismicio/client": "^4.0.0 || ^5.1.0",
|
|
31
|
-
"@prismicio/vue": "^2.0
|
|
31
|
+
"@prismicio/vue": "^2.1.0",
|
|
32
32
|
"consola": "^2.15.3",
|
|
33
33
|
"prismic-dom": "^2.2.6"
|
|
34
34
|
},
|
package/src/module.js
CHANGED
|
@@ -6,6 +6,7 @@ const generate = require('./generator')
|
|
|
6
6
|
function install (moduleOptions) {
|
|
7
7
|
const options = {
|
|
8
8
|
preview: true,
|
|
9
|
+
previewReloadType: 'hot',
|
|
9
10
|
components: true,
|
|
10
11
|
modern: false,
|
|
11
12
|
...moduleOptions,
|
|
@@ -75,6 +76,7 @@ function install (moduleOptions) {
|
|
|
75
76
|
src: path.resolve(__dirname, '../templates/plugins/prismic.js'),
|
|
76
77
|
options: {
|
|
77
78
|
preview: options.preview,
|
|
79
|
+
previewReloadType: options.previewReloadType,
|
|
78
80
|
endpoint: options.endpoint,
|
|
79
81
|
modern: options.modern,
|
|
80
82
|
apiOptions,
|
|
@@ -101,11 +101,23 @@ export default async (context, inject) => {
|
|
|
101
101
|
<% if (options.preview) { %>
|
|
102
102
|
// Load prismic script after Nuxt app is mounted
|
|
103
103
|
if (process.client) {
|
|
104
|
-
window.<%= globals.readyCallback %> && window.<%= globals.readyCallback %>(() => {
|
|
104
|
+
window.<%= globals.readyCallback %> && window.<%= globals.readyCallback %>((app) => {
|
|
105
105
|
const script = document.createElement('script')
|
|
106
106
|
|
|
107
107
|
script.src = '<%= options.script %>'
|
|
108
108
|
document.body.appendChild(script)
|
|
109
|
+
|
|
110
|
+
<% if (options.previewReloadType === 'hot') { %>
|
|
111
|
+
window.addEventListener('prismicPreviewUpdate', async (event) => {
|
|
112
|
+
if (app && 'refresh' in app && typeof app.refresh === 'function') {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (app.$store && app.$store._actions.nuxtServerInit) {
|
|
115
|
+
await app.$store.dispatch('nuxtServerInit', app.$options.context)
|
|
116
|
+
}
|
|
117
|
+
await app.refresh();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
<% } %>
|
|
109
121
|
})
|
|
110
122
|
}
|
|
111
123
|
// Preview mode
|