Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live Preview #1054

Open
1 task done
titouan-pellerin opened this issue Jan 6, 2025 · 3 comments
Open
1 task done

Live Preview #1054

titouan-pellerin opened this issue Jan 6, 2025 · 3 comments
Labels
feature [Issue] New feature or request

Comments

@titouan-pellerin
Copy link

Description

I noticed your upcoming update for the live preview and was wondering—why fetch the data again using an SSR version of the site instead of just updating the DOM by passing the data directly to the iframe? I’m guessing it’s because mapping all Storyblok fields to specific DOM elements is tricky. It would be so convenient if the Visual Editor could simply load the static version of the site, rather than relying on a dedicated SSR endpoint.

Suggested solution or improvement

A potential improvement could involve enabling the Visual Editor to load a static version of the site and dynamically update the DOM using bridge events for hydration. This approach would remove the dependency on an SSR-specific endpoint, streamline the process, and make better use of existing static assets while reducing overhead.

Additional context

No response

Validations

@titouan-pellerin titouan-pellerin added pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Jan 6, 2025
@titouan-pellerin
Copy link
Author

Contentful CMS preview relies on a similar approach, where a static version of the site is loaded, and the DOM is dynamically updated using iframe events.

https://github.com/contentful/live-preview

@dipankarmaikap
Copy link
Contributor

Hey @titouan-pellerin
Thank you for the feedback!

Astro ships with no client-side JavaScript by default, which makes live previews more challenging compared to reactive frameworks like React, Vue, or Svelte. These frameworks support DOM updates through hydration, but Astro components can’t be rendered on the client side.

Our current approach is to render the full page on an SSR endpoint and then manipulate the DOM. While this works for now, we’re always exploring improvements. Astro’s experimental container API could enable a solution like the one you suggested in the future, though it’s currently server-side.

We appreciate your suggestion and will keep it in mind as we improve the SDK!

Best regards,

@dipankarmaikap dipankarmaikap added feature [Issue] New feature or request and removed pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Jan 14, 2025
@titouan-pellerin
Copy link
Author

Hey @dipankarmaikap,

I know what you mean, although it's doable with vanilla javascript with data-attribute to map real dom elements to storyblok fields. I agree that in some cases this could be difficult to manage, for complex components like repeaters for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature [Issue] New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants