@nuxtjs/prismic 1.3.2 → 1.4.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/prismic",
3
- "version": "1.3.2",
3
+ "version": "1.4.2",
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.11",
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,
@@ -9,6 +9,7 @@
9
9
 
10
10
  <script>
11
11
  export default {
12
+ nuxtI18n: false,
12
13
  head: {
13
14
  title: 'Prismic Preview'
14
15
  },
@@ -34,6 +34,9 @@ export default async (context, inject) => {
34
34
  apiEndpoint() {
35
35
  return '<%= options.endpoint %>'
36
36
  },
37
+ predicate() {
38
+ return Prismic.Predicates
39
+ },
37
40
  predicates() {
38
41
  return Prismic.Predicates
39
42
  },
@@ -42,6 +45,9 @@ export default async (context, inject) => {
42
45
  }
43
46
  },
44
47
  methods: {
48
+ asHTML(richText) {
49
+ return this.asHtml(richText)
50
+ },
45
51
  asHtml(richText) {
46
52
  if (richText) {
47
53
  return PrismicDOM.RichText.asHtml(
@@ -101,11 +107,23 @@ export default async (context, inject) => {
101
107
  <% if (options.preview) { %>
102
108
  // Load prismic script after Nuxt app is mounted
103
109
  if (process.client) {
104
- window.<%= globals.readyCallback %> && window.<%= globals.readyCallback %>(() => {
110
+ window.<%= globals.readyCallback %> && window.<%= globals.readyCallback %>((app) => {
105
111
  const script = document.createElement('script')
106
112
 
107
113
  script.src = '<%= options.script %>'
108
114
  document.body.appendChild(script)
115
+
116
+ <% if (options.previewReloadType === 'hot') { %>
117
+ window.addEventListener('prismicPreviewUpdate', async (event) => {
118
+ if (app && 'refresh' in app && typeof app.refresh === 'function') {
119
+ event.preventDefault();
120
+ if (app.$store && app.$store._actions.nuxtServerInit) {
121
+ await app.$store.dispatch('nuxtServerInit', app.$options.context)
122
+ }
123
+ await app.refresh();
124
+ }
125
+ });
126
+ <% } %>
109
127
  })
110
128
  }
111
129
  // Preview mode