Reputation: 97
A project in our company was built using Astro and Svelte. In this project, API calls have to be made to a CMS to create blog posts dynamically. I would like a way for my clients to write blog posts, update the CMS(GraphCMS) and see that the website has created a new post.
Upvotes: 3
Views: 5029
Reputation: 485
There are 2 ways this can be done.
GraphCMS allows you to fire a web hook when an action is completed, in this case publish a blog post. You need to be hosting on something like Vercel or Netlify, but as long as your build system has a web hook trigger, it can accept the payload and rebuild the site. It'll take a minute or two to complete, but the person should be able to see the new content relatively quickly.
The other way, as other authors have suggested, is to use Astro with Svelte, React or some other client-side JS, and add a client-side router which can then fetch and render posts on the client. That's less efficient because your users will have to wait for data to be fetched, and it probably won't show up in search engines.
Upvotes: 2
Reputation: 433
If your company use Svelte, take a look at Sveltekit. See:
https://docs.astro.build/comparing-astro-vs-other-tools/#sveltekit-vs-astro
https://kit.svelte.dev/
https://svelteland.github.io/svelte-kit-blog-demo/create-your-blog/
Upvotes: 1