Skip to content

Commit

Permalink
docs: add information to preview mode (#534)
Browse files Browse the repository at this point in the history
* docs: add information to preview mode

* [Update] Remove example

Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
  • Loading branch information
mornir and Atinux committed Aug 28, 2020
1 parent 253daa7 commit 10fdfb4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions content/en/guides/features/live-preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The preview mode will automatically refresh the page data as it uses `$nuxt.refr
In order to activate live preview you will need to add the following plugin:

```js{}[plugins/preview.client.js]
export default async function ({ query, enablePreview }) {
export default function ({ query, enablePreview }) {
if (query.preview) {
enablePreview()
}
Expand Down Expand Up @@ -64,17 +64,23 @@ enablePreview should be tested locally with yarn start and not yarn
dev
</base-alert>
For pages that are not yet generated, SPA fallback will still call the API before showing the 404 page as these pages exist on the API but are not re-generated yet
### Previewing pages that are not yet generated
For pages that are not generated and don't exist on the API, for example draft content in your CMS that is not publicly available, you will need to use the validate hook:
For pages that are not yet generated, SPA fallback will still call the API before showing the 404 page as these pages exist on the API but are not generated yet.
If you have set a validate hook, you will probably need to modify it so that it doesn't redirect to the 404 page in preview mode.
```js
async validate({ app, params, $preview }) {
if ($preview) {
validate({ params, query }) {
if (query.preview) {
return true
}
```
### Passing data to enablePreview
You can pass data to the `enablePreview` function. That data will then be available on the `$preview` context helper and on `this.$preview`.
### What's next
<base-alert type="next">
Expand Down

0 comments on commit 10fdfb4

Please sign in to comment.