Skip to content

Import a component into a markdown file #3059

Answered by dbzx10299
dbzx10299 asked this question in Q&A
Discussion options

You must be logged in to vote

Solution

I did finally find a way to do this, I did not want to put the entire design system in the content dir and at the same time I can't make everything global since in some places I need to import the components to create components with render functions.

If we have a page for example with legal content and want to import a grid cell component so we can use just that on our legal pages we can inject it with the content renderer.

/pages/lega/[...slug].vue

<script setup>
import GridCell from '#components'
</script>

<template>
  <ContentRenderer :components="{ GridCell }" />
</template>

This way we can use it in a markdown file

## Privacy Policy

::GridCell
some info about the policy
::

Replies: 1 comment

Comment options

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