0
votes

I am doing a website using Nuxt.js and Contentful to show a list of courses. I have created a content model for courses on Contentful. Each course has a description. When I retrieve the description on Nuxt.js, the text comes out in one single paragraph. I want to show some formatting, at least line breaks. The text, apparently, can show markdown tags, - Is there any package, functionality, etc. that I can use to convert those tags to HTML? Thanks.

I have made the description just text but I also tried using Rich Text with the same output, all text in one line.

2

2 Answers

0
votes

I found the answer to this.

modules: [
  '@nuxtjs/markdownit'
],
markdownit: {
  injected: true
},
  • Finally, on the page for the course.
    <div v-html="$md.render(course.fields.fulldescription)"></div>
0
votes

If you use rich text react renderer with the Rich Text field, you can define custom rendering for your text nodes using the following line in options:

const options = {
 renderText: text => text.split('\n').flatMap((text, i) => [i > 0 && <br />, 
 text])
}

This will find and replace \n with
in your text nodes.