-
Notifications
You must be signed in to change notification settings - Fork 46
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
Automatically fetch new data on generated sites when in the editor #423
Comments
I have been looking into this for a few weeks but still have no solution how to make the Storyblok visual editor work properly using Nuxt 3 and SSG. As mentioned, this was a very simple matter on Nuxt 2 using |
I really want to see this feature as well. Actually this is even so important, that I just can not transfer this to my clients.... They just don't understand what happens. Is there any news on this, because this is really critical. I also tried to load draft data when in preview etc, but everytime I hit save, it changes back to the generated content. Location.reload(false) also isn't doing anything. |
We really need this feature as well and I have created a funky work around that worked for me. We can flush the cache when you click the save button in the visual editor. How we did itThis is how we fetch data from Storyblok, we dont use
We use the So what I did was this:
If the page loads on the client side and is in an iframe, use By doing this, the An official and less funky solution would be nice, but maybe this could help for the moment for some. |
Thank you @Adamkillander96 for your solution, but as you mentioned without the pipeline it wont work. And it's also not real time update as with Nuxt 2 and const route = useRoute();
const slug = route.path.replace(/\/$/, '');
const story = ref();
const storyblokApi = useStoryblokApi();
const preview = route.query._storyblok ? true : false;
const { data } = await useAsyncData(
preview ? 'story-preview' : 'story',
async () =>
await storyblokApi.get(`cdn/stories/${slug}`, {
version: preview ? 'draft' : 'published',
})
);
story.value = data.value?.data.story;
onMounted(() => {
useStoryblokBridge(story.value?.id, (evStory) => (story.value = evStory));
}); I also want to stress how important this is, not being able to use the visual editor is making it impossible to hand over any statically hosted project using Nuxt 3 to a client. |
Is this only for generated sites, not on normal hybrid nuxt3 apps? |
I dove a little bit deeper down into problem and decided to set up a few simple tests on a dedicated Netlify site. Neither |
@Dawntraoz, could you maybe give us an update on this feature? It seems that more and more people are struggling with this... |
It's a bit concerning that this ticket has been open for quite a while without any response from the devs. Given the importance of the bug and the relative high subscription prices we pay for this product, one would expect a quicker resolution or at least a response. Just sharing my thoughts on this. Thanks! |
After my earlier rant, I actually stumbled upon something interesting. It seems like the issue might have been sorted out in one of the recent releases since August 10. I've noticed that all those warnings etcetera in my console have vanished when using the editor with the SSR Netlify preview link. Plus, the edits I've been making in the editor are behaving themselves. So, hey @stijns96 and @SebbeJohansson, maybe giving the latest version a shot could do the trick for you too. |
Hi @ItsMeDelanoDev, SSR should work indeed, but the problem is with SSG. This was working with nuxt 2 and not with nuxt 3. How do you get a SSR preview link? That totally depends on the command you run right? |
Besides my stupid mistake I meant Netlify SSG.
False alarm after all, while experimenting it seemed to work way better than before. Yet now once again fields are no longer updating real time on our Netlify deploy-preview and production pages. We are running |
Years ago, before For Netlify it can look something like this: export default defineNuxtConfig({
process.env.PREVIEW ? ssr: false : ssr:true,
runtimeConfig: {
public: {
version:
process.env.SITE_ENV === 'production' && !process.env.PREVIEW
? 'published'
: 'draft',
}
}
}); I still have some testing to do but this looks promising! |
i'm having some success with this solution: storyblok/nuxt-ultimate-tutorial#5 (comment) with it, the also note, that on static hosting, you have to make sure, that calls to non-existant sites get redirected to all in all, after working many hours on a prerendered nuxt+storyblok project i can only conclude: it is a veritable shit-show, with many weird effects and stuff not working correctly. :-/ EDIT: i've carved out yet another vue-core problem leading to a mashed up DOM, when removing a component: vuejs/core#9035 |
Hi folks 👋 As I've already mentioned to @codeflorist in his issue on this at UT repo: storyblok/nuxt-ultimate-tutorial#5 (comment), as I'm working on the last part of the Ultimate Tutorial (Preview environments & Deployment), I have the SSG with preview mode refreshing (as in Nuxt 2) working there. You can check here the [...slug].vue: https://github.com/storyblok/nuxt-ultimate-tutorial/blob/part-7/pages/%5B...slug%5D.vue Again, I hope this helps and can fix all the issues you were having 🤗 As I told to CodeFlorist, if you want to jump in a quick call to see the workaround together or discuss doubts, happy to help and add more insights on the tutorial thanks to your feedback! |
Thank you @Dawntraoz, your solution is a lot leaner than my take on the problem :) However I get
whenever I click on a block in the visual preview and the editor does not focus on the block. Is this working on your end? My templates should be good, this is working using my solution. |
@henrikhansson indeed should be working, probably worth checking out the differences with main: storyblok/nuxt-ultimate-tutorial@main...part-7, just in case something is different in your solution 🤔 |
The article is now live! Please check it out and let me know your feedback: https://www.storyblok.com/tp/create-a-preview-environment-for-your-nuxt-3-website 💜 I will close the issue since this resolves the topic, no need to update the SDK since it's implemented directly on the end project. Do you think will be helpful to update the README.md? If so, I will include it as reference 👌 |
In nuxt2 you could previously run
enablePreview()
to refetch data, maybe we can implement something like that?Expected Behavior
I expect the application to always fetch new data when in preview mode.
Current Behavior
Currently it displays pregenerated content.
Steps to Reproduce
useAsyncStoryblok
to fetch data in a generate nuxt3 application.Example code from Henrik Hansson:
Discussion from discord: https://discord.com/channels/700316478792138842/1111583846731882586
Discussion from nuxt github: nuxt/nuxt#15639 & nuxt/nuxt#18407 (comment)
The text was updated successfully, but these errors were encountered: