Skip to content

Commit 72822a7

Browse files
committed
#4124: Fixed initial Nuxt 3 SSR builder render issue by passing route params to isPreviewing()
1 parent 695390c commit 72822a7

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

examples/vue/nuxt-3-catchall/pages/[...app].vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div id="home">
33
<div>Hello world from your Vue project. Below is Builder Content:</div>
44

5-
<div v-if="content || isPreviewing()">
5+
<div v-if="canShowContent">
66
<div>
77
page title:
88
{{ content?.data?.title || 'Unpublished' }}
@@ -20,7 +20,7 @@
2020

2121
<script setup>
2222
import { Content, fetchOneEntry, isPreviewing } from '@builder.io/sdk-vue';
23-
23+
import { ref } from 'vue';
2424
import HelloWorldComponent from '../components/HelloWorld.vue';
2525
2626
// Register your Builder components
@@ -41,7 +41,7 @@ const REGISTERED_COMPONENTS = [
4141
4242
// TODO: enter your public API key
4343
const BUILDER_PUBLIC_API_KEY = 'f1a790f8c3204b3b8c5c1795aeac4660'; // ggignore
44-
44+
const canShowContent = ref(false);
4545
const route = useRoute();
4646
4747
// fetch builder content data
@@ -54,4 +54,5 @@ const { data: content } = await useAsyncData(`builderData-page-${route.path}`, (
5454
},
5555
})
5656
);
57+
canShowContent.value = content.value ? true : isPreviewing(route.query);
5758
</script>

examples/vue/nuxt-3/app.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div id="home">
33
<div>Hello world from your Vue project. Below is Builder Content:</div>
44

5-
<div v-if="content || isPreviewing()">
5+
<div v-if="canShowContent">
66
<div>
77
page title:
88
{{ content?.data?.title || 'Unpublished' }}
@@ -20,7 +20,7 @@
2020

2121
<script setup>
2222
import { Content, fetchOneEntry, isPreviewing } from '@builder.io/sdk-vue';
23-
23+
import { ref } from 'vue';
2424
import HelloWorldComponent from './components/HelloWorld.vue';
2525
2626
// Register your Builder components
@@ -41,7 +41,7 @@ const REGISTERED_COMPONENTS = [
4141
4242
// TODO: enter your public API key
4343
const BUILDER_PUBLIC_API_KEY = 'f1a790f8c3204b3b8c5c1795aeac4660'; // ggignore
44-
44+
const canShowContent = ref(false);
4545
const route = useRoute();
4646
4747
// fetch builder content data
@@ -54,4 +54,5 @@ const { data: content } = await useAsyncData(`builderData-page-${route.path}`, (
5454
},
5555
})
5656
);
57+
canShowContent.value = content.value ? true : isPreviewing(route.query);
5758
</script>

0 commit comments

Comments
 (0)