storyblok-rich-text-renderer icon indicating copy to clipboard operation
storyblok-rich-text-renderer copied to clipboard

"Rich Text Renderer not provided." when building and then using "nuxt start".

Open SebbeJohansson opened this issue 2 years ago • 12 comments

Hi. I am having issues rendering rich text in a built ssr = true and target = static environment. It is working fine when doing "nuxt dev", but building and then starting does not work. Am I doing something wrong?

image

You can find the full project here: https://github.com/SebbeJohansson/sebbejohansson-front/tree/features/nuxt3-storyblok

SebbeJohansson avatar Jun 21 '22 18:06 SebbeJohansson

Okay I gave up on using this rendering package and resorted to just using storyblokApi.richTextResolver.render() to render it. Since I am in nuxt3 with typescript and composition API the code looks like this for me:

<script setup lang="ts">
const props = defineProps({ blok: Object });
const storyblokApi = useStoryblokApi();
const text = computed((): string => storyblokApi.richTextResolver.render(props.blok.text));
</script>

<template>
  <div v-editable="blok" class="text">
    <div v-html="text" />
  </div>
</template>

This works in all rendering cases I have tested and I have fully deployed the site to netlify.

SebbeJohansson avatar Jun 21 '22 21:06 SebbeJohansson

I found the solution there #21 Add to your config build: { transpile: ["@marvr/storyblok-rich-text-vue-renderer"], }

houdiini avatar Jul 20 '22 15:07 houdiini

I found the solution there #21 Add to your config build: { transpile: ["@marvr/storyblok-rich-text-vue-renderer"], }

@houdiini Nope sadly it does not work. I've had that on from the start.

SebbeJohansson avatar Jul 21 '22 11:07 SebbeJohansson

@SebbeJohansson at least in my case, @houdiini 's solution worked (nuxt 3 rc6, netlify deploy).

arpadgabor avatar Aug 10 '22 22:08 arpadgabor

@arpadgabor With ssr = true and target = static?

SebbeJohansson avatar Aug 11 '22 13:08 SebbeJohansson

Adding the following plugin solved it for me in Nuxt 3:

import { plugin } from '@marvr/storyblok-rich-text-vue-renderer'

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(plugin())
})

DreaMinder avatar Aug 24 '22 21:08 DreaMinder

@DreaMinder Same question as for arpadgabor, did that work with ssr=true?

SebbeJohansson avatar Aug 25 '22 06:08 SebbeJohansson

@SebbeJohansson yes

DreaMinder avatar Aug 25 '22 06:08 DreaMinder

@DreaMinder Okay nice! Have you tested how that method performs compared to storyblokApi.richTextResolver.render(props.blok.text) in terms of performance?

SebbeJohansson avatar Aug 25 '22 08:08 SebbeJohansson

Sorry for not replying @SebbeJohansson , I also got it working with SSR and in the netlify build preset, no static builds.

arpadgabor avatar Aug 25 '22 09:08 arpadgabor

@SebbeJohansson I didn't do any benchmarks but when pregenerating 1k pages, there's no noticeable difference compared to rendering an html string into v-html (without richtext).

DreaMinder avatar Aug 25 '22 10:08 DreaMinder

Adding the following plugin solved it for me in Nuxt 3:

import { plugin } from '@marvr/storyblok-rich-text-vue-renderer'

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(plugin())
})

I still have the issue when generating for SSG, this didn't work.

alvarosabu avatar Sep 06 '22 08:09 alvarosabu