Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@teamnovu/statamic-live-preview-nuxt

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teamnovu/statamic-live-preview-nuxt - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

## [1.1.0](https://github.com/teamnovu/statamic-live-preview-nuxt/compare/v1.0.0...v1.1.0) (2022-04-27)
## 1.0.0 (2022-04-20)

@@ -0,1 +1,9 @@

function log(...message) {
console.log(
'%cLive Preview',
'color: white; background-color: #ff269e; padding: 2px 4px; border-radius: 2px;',
...message
)
}
module.exports = ({ app, query, $axios, $graphql, enablePreview }) => {

@@ -24,3 +32,3 @@ // Add token to new route query when changing route

'live-preview': from.query['live-preview'],
}
},
},

@@ -33,3 +41,3 @@ })

if ($axios) {
$axios.onRequest(config => {
$axios.onRequest((config) => {
if (!query.token) {

@@ -43,3 +51,3 @@ return config

token: query.token,
}
},
}

@@ -56,3 +64,3 @@ })

Object.keys($graphql).forEach(key => {
Object.keys($graphql).forEach((key) => {
$graphql[key].url = `${$graphql[key].url}?token=${to.query.token}`

@@ -63,6 +71,16 @@ })

// Enable preview mode for static sites
if (process.client && query.token) {
log('Enabling preview mode...')
// Enable preview mode for static sites
enablePreview?.()
// Add live preview update event handler
window.onmessage = function (e) {
if (e.data === 'live-preview-update') {
log('Refreshing page...')
window.$nuxt?.refresh()
}
}
}
}

2

package.json
{
"name": "@teamnovu/statamic-live-preview-nuxt",
"version": "1.0.0",
"version": "1.1.0",
"description": "A Nuxt.js Plugin for the Statamic Live Preview",

@@ -5,0 +5,0 @@ "private": false,

@@ -11,2 +11,6 @@ # Statamic Live Preview for Nuxt

If you are migrating from the previous statamic live preview provided by our fork, please also remove the old statamic live preview module:
`yarn remove statamic-live-preview-nuxt`
### Add plugin to your nuxt config

@@ -18,4 +22,4 @@

```
import livePreview from 'statamic-live-preview-nuxt'
```javascript
import livePreview from '@teamnovu/statamic-live-preview-nuxt'

@@ -27,7 +31,26 @@ export default livePreview

```
```javascript
plugins: [
...
// ...
'~/plugins/live-preview.js'
]
```
```
### Statamic 3.3 Fork using `window.postMessage()`
If you are using our Statamic 3.3 fork you can set the CMS to update the live preview without having it refresh the page after every change.
To do so set the config `post_message_data` in `config/statamic/live_preview.php` to `live-preview-update`.
This will tell the CMS to use `window.postMessage()` to notify this plugin to refresh the page.
### Transpilation
Depending on your Node-version you may need to add the package to be transpiled by nuxt.
```javascript
build: {
transpile: [
// ...
'@teamnovu/statamic-live-preview-nuxt'
]
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc