miaolz123 / vue-markdown

A Powerful and Highspeed Markdown Parser for Vue
https://miaolz123.github.io/vue-markdown/
MIT License
1.89k stars 257 forks source link

Feature Request: compatibility with Server Side Rendering (SSR) #116

Closed robindierckx closed 4 years ago

robindierckx commented 4 years ago

In combination with nuxt, vue-markdown doesn't pre-render when running nuxt generate.

    <vue-markdown>{{ content }}</vue-markdown>

The element is there but, the content doesn't appear on the generated html page (the vue-markdown element is empty), although it works perfectly fine in spa mode. This is because the vue-markdown parsing logic is not executed in SSR mode. It would be great to add this feature, or offer the possibility to pre-process the html in nuxt's asyncData or fetch function.

robindierckx commented 4 years ago

Please see the response of the nuxt team:

If you check the source of the component, you can see that the initialization of this.sourceData is done in the beforeMount lifecycle hook. Unfortunately, that hook is not run by Vue when doing SSR, so there's nothing to do on Nuxt or Vue side. That library is not compatible with SSR

How can we make this plugin compatible with SSR ?

robindierckx commented 4 years ago

Solution was to define source directly

<vue-markdown :source = content ></vue-markdown>