hmsk / vite-plugin-markdown

A vite plugin to import a Markdown file in various formats like Front Matter, HTML, ToC, and React/Vue Component
https://www.npmjs.com/package/vite-plugin-markdown
MIT License
259 stars 44 forks source link

Allow passing more options to VueComponentWith() #134

Open steffans opened 3 years ago

steffans commented 3 years ago

It would be nice to allow other Vue Component options then components when using Vue syntax in .md file. For example props can be useful as well. There could be a second function parameter called options, like so: VueComponentWith(components, options)

import { VueComponentWith } from '../contents/test.md';

const TestComponent = VueComponentWith({ ... }, {
   props: ['prop1', ...]
});
hmsk commented 3 years ago

Interesting. Could you share your real world use-cases which the feature helps/solves?

steffans commented 3 years ago

Actually i would use it with ˋpropsˋ which i needed on the components i also passed to the markdown markup. Could be also useful to pass props with additional data like done in Vuepress. See: https://vuepress.vuejs.org/guide/using-vue.html#templating

hmsk commented 3 years ago

Got it. I was interested in what you try to make actually in the "real world". What you're building, what the feature you suggested solves 😉

See: https://vuepress.vuejs.org/guide/using-vue.html#templating

I'm not so keen on supporting templating features like VuePress basically and would recommend using MDX for more dynamic handling.

steffans commented 3 years ago

The 'templating' hash of the doc was not precise, i use it to pass props which i can use on the passed components. Like this:

# Headline

<my-component :some-prop="myProp"/>

Other text ....
hmsk commented 3 years ago

so actually what makes happen by <my-component :some-prop="myProp"/> ?