Contentful logo

Contentful Community

richTextHtml in a v-for (and with no warnings)

#1

Hello,

Using Contentful with Nuxt.js, I’ve been able to render some rich text as a variable

richTextHtml: documentToHtmlString(posts.items[0].fields.text)

injected into the template with

<div v-html="richTextHtml" />

However, I am facing 2 problems.

  • The first is that I get a ‘v-html’ directive can lead to XSS attack from eslint

  • The second, is that I am totally new to Vue.js, so as I am able to create a v-for which generates all my blog posts, I can’t understand how I can convert my data to HTML inside the v-for, and not as a static variable outside of it.

This might be mainly a lack of my knowledges, but I couldn’t find any help around. Happy if anyone could show me the light :slight_smile:

0 Likes