unplugin / unplugin-vue-markdown

Compile Markdown to Vue component
MIT License
506 stars 26 forks source link

[Discussion/Question] Can I pass props into my Markdown components and have them rendered within the Markdown component? #36

Open cjholowatyj opened 7 months ago

cjholowatyj commented 7 months ago

Can I pass props into my Markdown components and have them rendered within the Markdown component? For example, would I be able to do something like...

<!-- Page.vue -->
<template>
    <MarkdownComponent :slogan="markdownSlogan"/>
</template>

<script setup>
import MarkdownComponent from 'markdown-component.md';
const markdownSlogan = "Here we grow again!";
</script>
<!-- markdown-component.md -->
# Title

## {{ props.slogan }}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus rutrum risus lacus, ...

If this functionality is already available, it is not clearly documented in the README.md. If it isn't already available Please consider this a feature request!

FlickerSoul commented 4 months ago

You can use <script setup> in your markdown file so theoretically I think you can use defineProps and get props working.