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: docusaurus/docs/cloud/projects/settings.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -414,8 +414,23 @@ Environment variables (more information in the [Developer Documentation](../../d
414
414
}}
415
415
/>
416
416
417
-
In the <Iconname="code"classes="ph-bold" /> *Variables* tab, you can:
418
-
- click the **Add variable** button to create a new variable
419
-
- edit any variable, each being composed of a *Name* and a *Value*
420
-
- click the <Iconname="trash-simple" /> delete button associated with any non-default variable to delete it
421
-
- click the **Save** button to save any change made on the page
417
+
In the <Iconname="code"classes="ph-bold" /> *Variables* tab are listed both the default and custom environment variables for your Strapi Cloud project. Each variable is composed of a *Name* and a *Value*.
418
+
419
+
#### Managing environment variables
420
+
421
+
Hovering on an environment variable, either default or custom, displays the following available options:
422
+
423
+
- <Iconname="eye" /> **Show value** to replace the `*` characters with the actual value of a variable.
424
+
- <Iconname="copy" /> **Copy to clipboard** to copy the value of a variable.
425
+
- <Iconname="dots-three" /> **Actions** to access the <Iconname="pencil-simple" /> Edit and <Iconname="trash-simple" /> Delete buttons. Both options are only available for custom environment variables.
426
+
- When editing a variable, don't forget to confirm the changes by clicking on **Save**.
427
+
- When deleting a variable, you will be asked to click on a **Confirm** button to confirm the deletion.
428
+
429
+
#### Creating custom environment variables
430
+
431
+
Custom environment variables can be created for the Strapi Cloud project. Make sure to redeploy your project after creating or editing an environment variable.
432
+
433
+
1. In the *Custom environment variables* section, click on the **Add variable** button.
434
+
2. Write the *Name* and *Value* of the new environment variable in the same-named fields.
435
+
3. (optional) Click on **Add another** to directly create one or more other custom environment variables.
436
+
4. Click on the **Save** button to confirm the creation of the custom environment variables.
A more detailed example using the draft mode of Next.js is given in the [basic implementation guide](#3-add-handler-logic).
106
+
A more detailed example using the draft mode of Next.js is given in the [basic implementation guide](#3-add-handler).
105
107
106
108
## Basic implementation guide
107
109
108
-
Follow these steps to add Preview capabilities to your content types.
110
+
Follow these steps to add Preview capabilities to your content types in Strapi and your front-end.
111
+
112
+
This guide uses a basic Next.js example, but the process applies to all frameworks with some variations. Strapi-related steps (prefixed with [Strapi]) remain mostly the same. Please refer to your front-end framework's documentation for specific implementation details.
109
113
110
-
### 1. Create the Preview configuration
114
+
### 1. [Strapi]Create the Preview configuration {#1-create-config}
111
115
112
116
Create a new file `/config/admin.ts` (or update it if it exists) with the following basic structure:
Add the URL generation logic with a `getPreviewPathname` function. The following example is taken from the [Launchpad](https://github.com/strapi/LaunchPad/tree/feat/preview) Strapi demo application:
Some content types don't need to have a preview if it doesn't make sense, hence the default case returning `null`. A Global single type with some site metadata, for example, will not have a matching front-end page. In these cases, the handler function should return `null`, and the preview UI will not be shown in the admin panel. This is how you enable or disable preview per content type.
178
182
:::
179
183
180
-
### 3. Add handler logic
184
+
### 3. [Strapi]Add handler logic {#3-add-handler}
181
185
182
186
Create the complete configuration, expanding the basic configuration created in step 1. with the URL generation logic created in step 2., adding an appropriate handler logic:
### 4. [Front end]Set up the front-end preview route {#4-setup-frontend-route}
229
233
230
234
Setting up the front-end preview route is highly dependent on the framework used for your front-end application.
231
235
232
236
For instance, [Next.js draft mode](https://nextjs.org/docs/app/building-your-application/configuring/draft-mode) and
233
-
[Nuxt preview mode](https://nuxt.com/docs/api/composables/use-preview-mode) provide additional documentation on how to implement the front-end part in their respective documentations.
237
+
[Nuxt preview mode](https://nuxt.com/docs/api/composables/use-preview-mode) provide additional information on how to implement the front-end part in their respective documentations.
234
238
235
239
If using Next.js, a basic implementation could be like in the following example taken from the [Launchpad](https://github.com/strapi/LaunchPad/tree/feat/preview) Strapi demo application:
236
240
@@ -264,15 +268,100 @@ export async function GET(request: Request) {
264
268
}
265
269
```
266
270
267
-
### 5. Allow the front-end to be embedded
271
+
### 5. [Front end]Allow the front-end to be embedded {#5-allow-frontend-embed}
268
272
269
273
On the Strapi side, [the `allowedOrigins` configuration parameter](#allowed-origins) allows the admin panel to load the front-end window in an iframe. But allowing the embedding works both ways, so on the front-end side, you also need to allow the window to be embedded in Strapi's admin panel.
270
274
271
275
This requires the front-end application to have its own header directive, the CSP `frame-ancestors` directive. Setting this directive up depends on how your website is built. For instance, setting this up in Next.js requires a middleware configuration (see [Next.js docs](https://nextjs.org/docs/app/building-your-application/configuring/content-security-policy)).
272
276
277
+
### 6. [Front end] Detect changes in Strapi and refresh the front-end {#6-refresh-frontend}
278
+
279
+
Strapi emits a `strapiUpdate` message to inform the front end that data has changed.
280
+
281
+
To track this, within your front-end application, add an event listener to listen to events posted through [the `postMessage()` API](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) on the `window` object. The listener needs to filter through messages and react only to Strapi-initiated messages, then refresh the iframe content.
282
+
283
+
With Next.js, the recommended way to refresh the iframe content is with [the `router.refresh()` method](https://nextjs.org/docs/app/building-your-application/caching#routerrefresh).
In Next.js, [cache persistence](https://nextjs.org/docs/app/building-your-application/caching) may require additional steps. You might need to invalidate the cache by making an API call from the client side to the server, where the revalidation logic will be handled. Please refer to Next.js documentation for details, for instance with the [revalidatePath() method](https://nextjs.org/docs/app/building-your-application/caching#revalidatepath).
358
+
<br/>
359
+
360
+
</details>
361
+
273
362
### Nextsteps
274
363
275
-
Once the preview system is set up, you need to adapt your data fetching logic to handle draft content appropriately. This involves:
Copy file name to clipboardExpand all lines: docusaurus/docs/user-docs/content-manager/managing-relational-fields.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ To select the relevant relational field's entries:
95
95
3. Repeat step 2 until all relevant entries have been chosen.
96
96
97
97
:::tip
98
-
All selected entries are listed right below the drop-down list. Click on the name of an entry to be redirected to the edit view of the relational field's content-type. Make sure you save your page first, to avoid losing your last modifications.
98
+
All selected entries are listed right below the drop-down list. Click on the name of an entry to display a modal from where you will be able to edit the relational field's content-type. For now, you can only edit a relation on-the-fly, and not create a new one. This feature is currently in beta and only available if you installed Strapi with the beta flag, with the following command `npx create-strapi@beta`.
99
99
:::
100
100
101
101
To remove an entry, click on the cross button <Iconname="x"classes="ph-bold" /> in the selected entries list.
Copy file name to clipboardExpand all lines: docusaurus/docs/user-docs/content-manager/previewing-content.md
+11-13Lines changed: 11 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,38 +11,36 @@ tags:
11
11
12
12
With the Preview feature, you can preview your front end application directly from Strapi's admin panel. This is helpful to see how updates to your content in the Edit View of the Content Manager will affect the final result.
- The Strapi admin panel user should have read permissions for the content-type.
25
16
- The Preview feature should be configured in the code of the `config/admin` file (see [Developer Docs](/dev-docs/preview)).
26
17
- A front-end application should already be created and running so you can preview it.
18
+
- Additionally, the side panel is only available if you installed strapi with the beta flag, with the following command: `npx create-strapi@beta`.
27
19
:::
28
20
29
-
When the Preview feature is properly set up, an **Open preview** button is visible on the right in the Edit View of the Content Manager. Clicking it will display the preview of your content as it will appear in your front-end application, but directly within Strapi's the admin panel:
21
+
Once the Preview feature is properly set up, an **Open preview** button is visible on the right in the Edit View of the Content Manager. Clicking it will display a side panel with the preview of your content as it will appear in your front-end application, but directly within Strapi's the admin panel.
Once the side panel for the Preview is open, you can:
41
33
42
34
- click the close button  in the upper left corner to go back to the Edit View of the Content Manager,
43
35
- switch between previewing the draft and the published version (if [Draft & Publish](/user-docs/content-manager/saving-and-publishing-content) is enabled for the content-type),
36
+
- expand the side panel by clicking on the <Iconname="arrow-line-left"classes="ph-bold" /> button to make the Preview full screen
37
+
- use buttons at the top right of the editor to define the assignee and stage for the [Review Workflows feature](/user-docs/content-manager/reviewing-content) if enabled
44
38
- and click the link icon  in the upper right corner to copy the preview link. Depending on the preview tab you are currently viewing, this will either copy the link to the preview of the draft or the published version.
45
39
40
+
:::info
41
+
The side panel and its expand button are only available if you run the beta version of Strapi. In the stable version, the "Open Preview" button will open a full-screen preview.
42
+
:::
43
+
46
44
:::note
47
45
In the Edit view of the Content Manager, the Open preview button will be disabled if you have unsaved changes. Save your latest changes and you should be able to preview content again.
0 commit comments