QingWei-Li / vue-markdown-loader

📇 Convert Markdown file to Vue2.0 component.
704 stars 161 forks source link

Component inside markdown file #34

Closed metamn closed 6 years ago

metamn commented 6 years ago

Thank you for the plugin!

Is there a way to have Vue components inside the markdown file?

Thanks again!

metamn commented 6 years ago

I mean I want to insert responsive images and it seems srcset is not supported.

The following code inside a markdown file is not working:

<figure>
  <img src="/static/images/styleguide-architecture_tablet.png" srcset="/static/images/styleguide-architecture_mobile.png 420w, /static/images/styleguide-architecture_tablet.png 768w, /static/images/styleguide-architecture.png 1536w" alt="Styleguide architecture">
  <figcaption>Styleguide architecture</figcaption>
</figure>

And this code works (without srcset):

<figure>
  <img src="/static/images/styleguide-architecture_tablet.png" alt="Styleguide architecture">
  <figcaption>Styleguide architecture</figcaption>
</figure>
metamn commented 6 years ago

That's why I would like to use an image component

QingWei-Li commented 6 years ago

See https://vue-loader.vuejs.org/en/configurations/asset-url.html

metamn commented 6 years ago

Hmmm ... sorry I really don't understand the answer.

It tells me the srcset is not supported only the src:

CreateElement('img', { attrs: { src: require('../image.png') }})

Back to the original question ... can Vue components be used inside a markdown file?

QingWei-Li commented 6 years ago

You should upgrade vue-loader to ^13.0.0. See https://github.com/vuejs/vue-loader/commit/69fd7b02fbf8eeeac8513420364db6d8b65946bb

metamn commented 6 years ago

oh thanks :D