Skip to content

how to use ContentRenderer to render external API data #1974

Answered by ali4zimi
leosin asked this question in Q&A
Discussion options

You must be logged in to vote

For me, it is working. I have created a component named MarkdownRenderer with the following content:

<template>
  <ContentRenderer :value="parsedMarkdown" />
</template>

<script>
import { defineComponent } from 'vue'

import markdownParser from '@nuxt/content/transformers/markdown'

export default defineComponent({
  components: {},

  // define props
  props: {
    md: {
      type: String,
      default: '',
    },
    cid: {
      type: String,
      default: '<some-id>',
    },
  },

  // init
  async setup(props) {
    return {
      parsedMarkdown: await markdownParser.parse(props.cid, props.md),
    }
  },
})
</script>

and then call it like this:

<MarkdownRenderer :md="item.descri…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@leosin
Comment options

@ali4zimi
Comment options

Answer selected by leosin
@lionel-addvanto
Comment options

@leosin
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants