Hey folks!
Really confused on this one. Scoured the docs for a few hours and asked on the Discord, but alas. I’m getting some weird behavior in my project and not sure if I’m using the preview URL right. It seems to work, but only sort of. Should I be using a dynamic one?
Read on for the juicy details.
Builder content link
Builder public api key
add3bfefbde24699aeb53c5a1ad64377
What are you trying to accomplish
I’m writing a tutorial for integrating Builder with Astro. As a demo project for the tutorial I’m setting up a basic blog.
Project details:
- The blog uses a section model for each blog post, as per the Builder docs.
- It uses the REST API and no client-side JavaScript
- A webhook triggers a rebuild when I change content on Builder.
I have two things nagging me:
-
As it is now, I’m using a static preview URL and everything works already… kind of. There is a weird delay between changing the content on Builder and the content showing up. Sometimes I need to rebuild a few times. It’s weird. (See video below)
-
After scouring the docs and forums for a few hours, I still don’t understand the benefits and/or necessities of a dynamic preview URL. When is it useful? When is it necessary? Why should I use a dynamic one if a static one works already? It’s hard not to get obsessed with this, as the docs suggest that using it for a URL model like
mysite.xyz/.../${slug_to_a_blog_post}
is a prime use case - This is me! I just don’t understand what this would get me.
My goals:
- Build a static blog where the content updates reliably after making a change (see point 1 above)
- Understand a little better when and why somebody would use a dynamic preview URL. I wanna make an informed decision which one to use here. If both are possible, I wanna give learners a brief rundown of the PROs and CONs of each in the tutorial.
These two things might be related, and I might be misunderstanding something fundamental
Would love any input on this one.
PS. how do you make a dynamic preview URL static again? The field is greyed out and I can only click on the <>
code editor button. I’m currently working around this by simply returning a static URL there.
Screenshots or video link
Video demo of content sometimes updating… but not always:
… but later, when I ran the dev server and built the site the correct content appeared - up to date and all!
Code stack you are integrating Builder with
- Astro as my SSG
- Builder’s REST API: The blog is static with no client-side JavaScript. My content and pre-rendered HTML gets fetched via Builder’s REST API at build time. The only
<builder-component>
is on my preview page. - Deploy on Netlify: The site gets rebuilt using a webhook when making a change in the visual editor.
Reproducible code example
Repo on gitpod