Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Add preview mode #18

Open
pepijn-vanvlaanderen opened this issue May 19, 2023 · 6 comments
Open

Add preview mode #18

pepijn-vanvlaanderen opened this issue May 19, 2023 · 6 comments
Labels
pr: enhancement Refactorings / perfs / testing / translations

Comments

@pepijn-vanvlaanderen
Copy link

Would be interesting to have a preview/draft mode included in this starter as well.

@abrorAbdullaev
Copy link

Even if we implement the preview feature in UI, can we extend the admin and add there a preview button somewhere without modifying the base module of @strapi/strapi?

@pepijn-vanvlaanderen
Copy link
Author

Even if we implement the preview feature in UI, can we extend the admin and add there a preview button somewhere without modifying the base module of @strapi/strapi?

Yes, there are already numerous Strapi plugins that do that, this one seems closest:

@PaulBratslavsky
Copy link
Contributor

That is a great idea. Will add it to the list.

@rrubio
Copy link

rrubio commented Jul 19, 2023

@pepijn-vanvlaanderen were you successfull adding the preview buttom to this demo? i'm the getting some erorrs at my end.

Unhandled Runtime Error
Error: Cannot read properties of undefined (reading 'attributes')

Source
src/app/[lang]/[...slug]/page.tsx (18:22) @ attributes

  16 | const page = await getPageBySlug(params.slug, params.lang);
  17 | 
> 18 | if (!page.data[0].attributes?.seo) return FALLBACK_SEO;
     |                  ^
  19 | const metadata = page.data[0].attributes.seo
  20 | 
  21 | return {

@pepijn-vanvlaanderen
Copy link
Author

@rrubio it is actually very straightforward when you follow the guide here: https://nextjs.org/docs/app/building-your-application/configuring/draft-mode

You just need a custom /api/preview/route.ts where the draftMode gets enabled, after that cookie is set al your pages are dynamically rendered and you have your preview.

@PaulBratslavsky
Copy link
Contributor

I am going to keep this issue open for anyone wanting to add this as a PR. In terms of items on my list, this has lower priority.😅

@PaulBratslavsky PaulBratslavsky added the pr: enhancement Refactorings / perfs / testing / translations label Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr: enhancement Refactorings / perfs / testing / translations
Projects
None yet
Development

No branches or pull requests

4 participants