You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extensions/cms-live-preview/6.0.x/extensions/livePreview/README.md
+40-7Lines changed: 40 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,54 @@
2
2
3
3
With the Live Preview extension, you can instantly see changes in your content as you edit it. This extension provides a seamless experience for content creators, allowing them to visualize their work in real-time without needing to publish or refresh the page.
4
4
5
+
## Install extension
6
+
7
+
To install the extension run the following command inside your Webiny project:
8
+
9
+
```shell
10
+
yarn webiny extension cms-live-preview
11
+
```
12
+
13
+
Once installed make sure to configure your NextJs/NuxtJs/Angular frontend app to render the pages. To get started clone our reference nextjs app from here: https://github.com/webiny/learn-webiny-nextjs-app/tree/live-preview-ext
14
+
Install the dependencies and run the dev server (`yarn dev`)
15
+
16
+
5
17

6
18
7
-
# Overview
19
+
##Overview
8
20
9
21
This extension consists of:
10
22
11
23
-**Admin Interface**: a preview pane on the left side of the screen that updates in real-time as you edit content on the right side.
12
24
-**Article Model**: a simple content model with a couple of fields
13
25
14
-
The extension works with a Next.js app which you can clone and host locally.
26
+
To add a live preview to an additional content model:
27
+
1. Modify `~/extensions/livePreview/admin/AddPreviewPane.tsx` - fine the line below and add your model id to the list:
Clone the app from here: https://github.com/webiny/learn-webiny-nextjs-app/tree/live-preview-ext
32
+
2. Modify `~/extensions/livePreview/admin/getPreviewUrl.ts` - modify the `previewPaths` and add the preview slug for your new content model:
33
+
```ts
34
+
const previewPaths:Record<string, string> = {
35
+
article: "/articles/preview",
36
+
example: "/examples/preview"
37
+
};
38
+
```
39
+
At the same time also add the `slugPaths`:
40
+
```ts
41
+
const slugPaths:Record<string, string> = {
42
+
article: "/articles",
43
+
example: "/examples"
44
+
};
45
+
```
17
46
18
-
Once cloned, install dependencies and run the development server:
47
+
The `previewPaths` variable tell the live preview component - what path to use in your app to render the live preview iframe inside your app for this particular content model.
48
+
The `slugPaths` is used together with the value of the `slug` field to compose a path for that entry. For example if we have `/test/path` as the value of the slug field in the example content model, the full slug will look like `/examples/test/path`, and that will be the route that your frontend app will need to handle to render this page.
19
49
20
-
```bash
21
-
yarn dev
22
-
```
50
+
3. Inside the same `~/extensions/livePreview/admin/getPreviewUrl.ts` file, also modify the `getDomain` function so it returns the live domain of your frontend app.
51
+
52
+
53
+
## Questions
54
+
55
+
In case of any questions, find us on our community forum: https://www.webiny.com/slack
0 commit comments