vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.53k stars 4.76k forks source link

get global markdown renderer inside Vue Component #559

Closed mrzzcn closed 6 years ago

mrzzcn commented 6 years ago

Feature request

What problem does this feature solve?

Customize some content inside Vue Component and output as MD

What does the proposed API look like?

<template>
  <p v-html="content">
  </p>
</template>
<script>
const mdRenderer = global.mdRenderer();
export default {
  data() {
    return { content: mdRenderer.render('## custom content')}
  }
}
</script>

How should this be implemented in your opinion?

  1. set a entry point in vuepress project
  2. add something to global

Are you willing to work on this yourself?**

Yes

ycmjason commented 6 years ago

I suggested something similar in https://github.com/vuejs/vuepress/issues/209.

ulivz commented 6 years ago

Sorry but for now we cannot expose the md instance to the client side for now, since our internal markdown parser depends on some Node-only APIs. and it's also too heavy.

FYI: All things that can be done in compilation should be done in compilation. Please wait for the plugin API that you can use extendPageData to add you customized markdown pre-rendered snippets for each page.

mrzzcn commented 6 years ago

I just need to do this between build process, not in the client side. but, Ok, I'll find some other way