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
Nuxt components inside Storyblok Rich-Text editor #22
Comments
Hi @cetchells. Am i understanding it correctly that you are wondering about adding blocks using this feature? I have not tested that. I can take a look during next week if you want? |
Yeh exactly that. |
Hm okay interesting. Since i am using Here you can see that it completely removes the blok node: I didn't have much time to look at this today, but I have a work in progress version: <script setup lang="ts">
import { Richtext } from 'storyblok-js-client';
const props = defineProps({ blok: Object });
const nuxtApp = useNuxtApp();
const textObject = { ...props.blok.text };
const nodes = [];
Object.entries(textObject.content).forEach(([key, node]) => {
if (node.type === 'blok') {
const blok = {
content: node.attrs?.body?.[0],
};
nodes.push({
key,
type: 'blok',
content: {
blok,
},
});
} else {
nodes.push({
key,
type: 'html',
content: nuxtApp.$formatRichText(useStoryblokApi().richTextResolver.render({
type: 'doc',
content: [
node,
],
} as Richtext)),
});
}
});
</script>
<template>
<div v-editable="blok" class="text">
<div v-for="node in nodes" :key="node.key">
<component
:is="$resolveStoryBlokComponent(node.content.blok)"
v-if="node.type === 'blok'"
:blok="node.content.blok.content"
/>
<div v-else v-html="node.content" />
</div>
</div>
</template>
<style>
.text img {
max-width: 100%;
}
</style> What I do: Let me know if any of this was confusing. I will most likely refactor this when I have more time and add it to my finished code in production. |
I made a blogpost about this: https://sebbejohansson.com/blog/storyblok-richtext-in-line-block-support-for-nuxt3-with-ssr-and-prerender |
I saw your post here: nuxt static, really helpful.
I had a look at nuxt3 and storyblok just wondering if you got components in richtext editor to resolve in nuxt3.
Suggestions below don't seem to work
https://www.storyblok.com/tp/nuxt-components-inside-rich-text
The text was updated successfully, but these errors were encountered: