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

Cant use useRoute and useStoryBlok in the same <script setup> #83

Open
fyoudine opened this issue Dec 1, 2022 · 4 comments
Open

Cant use useRoute and useStoryBlok in the same <script setup> #83

fyoudine opened this issue Dec 1, 2022 · 4 comments

Comments

@fyoudine
Copy link

fyoudine commented Dec 1, 2022

Expected Behavior

I'd like to retrieve data from storyblok using a dynamic slug

Current Behavior

When I hit the server it crash an error with no explanation

this works :

<script setup>
import { useStoryblok } from '@storyblok/nuxt-2'

const { story } = useStoryblok('mentions-legales', {
  version: 'draft'
})
</script>

<template>
  <div>
    <p>{{ slug }}</p>
    <StoryblokComponent v-if="story" :blok="story.content" />
  </div>
</template>

image

this works too :

<script setup>
import { computed, useRoute } from '@nuxtjs/composition-api'

const route = useRoute()
const slug = computed(() => route.value.params.slug)
</script>

<template>
  <div>
    <p>{{ slug }}</p>
    <StoryblokComponent v-if="story" :blok="story.content" />
  </div>
</template>

image

but this does not work

<script setup>
import { computed, useRoute } from '@nuxtjs/composition-api'
import { useStoryblok } from '@storyblok/nuxt-2'

const route = useRoute()
const slug = computed(() => route.value.params.slug)

const { story } = useStoryblok('mentions-legales', {
  version: 'draft'
})

</script>

<template>
  <div>
    <p>{{ slug }}</p>
    <StoryblokComponent v-if="story" :blok="story.content" />
  </div>
</template>

image

any hint to make it work is welcomed

@alexjoverm
Copy link
Contributor

Hey @fyoudine! That's really weird, I'm actually able to reproduce it and tried different things in our module but always getting the same result. Seems like it's failing on @nuxtjs/composition-api

image

@alexjoverm
Copy link
Contributor

alexjoverm commented Dec 15, 2022

I'd say the best workaround for now would be to use @storyblok/vue-2 directly.

@alexjoverm
Copy link
Contributor

Btw, @fyoudine it would really help us if you also open an issue on the @nuxtjs/composition-api repo :)

@simon-ccoms
Copy link

I'm seeing this exact issue as well - I'm not sure how to get around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants