Open Dawntraoz opened 9 months ago
Hi @Dawntraoz this will be really easy to achieve with the new richtext https://github.com/storyblok/richtext
Hi @alvarosabu, that sounds amazing! Thanks for caring 🎉 Can you share here or in the Nuxt issue the workaround proposed, and when will it be stable to use?
Yes, @Dawntraoz they could do something like this:
// Vanilla
const options = {
resolvers: {
[MarkTypes.LINK]: (node) => {
if node.attrs?.linktype === 'STORY' {
return `<a href="/${node.attrs?.href}"`
}
},
}
const html = richTextResolver<string>(options).render(doc)
Expected Behavior
The link should be rendered as
<a href="<URL>" ...>
, instead of<a href="<slug>" ...>
.Current Behavior
A user (@mlalitthapa) using our Nuxt SDK reported this issue: https://github.com/storyblok/storyblok-nuxt/issues/756.
He's using the internal link inside a rich text editor and rendering it using
renderRichText
function. But the anchor link is using the wrong URL in the href. Let's say his contact page has URL/contact
and slug ofcontact
. Then the anchor link is just usingcontact
as URL, instead of/contact
.Steps to Reproduce