nuxt-modules / prismic

Easily connect your Nuxt.js application to your content hosted on Prismic

Home Page:https://prismic.nuxtjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Layouts Preview does not work when building in full static mode

yannbertrand opened this issue · comments

Versions

  • nuxt: 2.15.7
  • @nuxtjs/prismic: 1.3.2
  • node: 16.10.0

Reproduction

Reproduction repository :
https://github.com/yannbertrand/prismic-nuxt-preview-test

Built app with a beta header : ✅ works after static build
https://prismic.link/3cLAI4o

Screenshots Prismic config

Result


Dev app with a beta footer : ✅ works before static build

Screenshots #### Prismic config

Result


Built app with a beta footer : ❌ does not work after static build
https://prismic.link/3cLCwud

Screenshots #### Prismic config

Result

Steps to reproduce

  1. Clone the repository
  2. Install deps npm install
  3. Change the PRISMIC_APIS_HREF value in nuxt.config.js to one you created (*see next section "Prismic config")
  4. Launch the project with npm run dev
  5. Activate Prismic preview mode on the local env for the main_footer
  6. See that it is really previewed on the footer layout element
  7. Stop the dev server
  8. Build the project using npm run build
  9. Launch the statically build project server locally npm run start
  10. See that the preview does not work on the footer layout element

Prismic config

Here is the Prismic setup I used (but you should be able to tweak it and reproduce the issue):

  • Custom Type - slices_page with a URI uid field and both banner_title + banner_content RTE fields
  • Custom Type - main_footer with a footer_forselect field (with pix-site default value) and a text RTE paragraph field
  • A published fr-fr Slices page with the URI index-pix-site with a running modification (ready to be previewed)
  • A published fr-fr Main footer with the footer_for=pix-site with a running modification (ready to be previewed)

What is Expected?

Preview mode should work the same way in Developpement+SSR+Static and after Full Static build.

What is actually happening?

Preview mode works the same way on page elements, but not on layout instantiated component.

commented

Hey there, thank you so much for the detailled report! I'll have a look at it next week.

At first glance it looks like this is probably related to the following: nuxt/nuxt#9439

I'll investigate that!

Thank you for your help! Let me know if you need more information :)

commented

Hey there,

Thanks to your detailed instruction I was able to reproduce easily the behavior you encountered.

So the issue here is the one described in this Nuxt issue: nuxt/nuxt#9439 (the one from before), but tl;dr; Nuxt is not able to refresh fetch hooks coming directly from a layout file (not a page).

I'll try to push for the PR fixing that to be merged. In the meantime, I'd recommend setting layouts data through the store rather than with the fetch hook, You can also stay like that, assuming that it's fine for you to not have previews working with layouts (while it might be more critical for blog posts for example)

Thank you for the update and providing a temporary patch! We'll definitely look into using the store to get data.

Is it ok to keep this issue open until the PR you mention is merged? It would be the best for us to get updated :)

commented

Definitely ☺️ This is still a valid "bug"

commented

Sadly the PR fixing this one on Nuxt end (nuxt/nuxt#9530) won't land as Nuxt team shifts its effort toward Nuxt 3.

I'm closing it with a wontfix flag and will update it should the PR change its status.