ravenq / markdown-it-vue

The vue lib for markdown-it.
MIT License
346 stars 70 forks source link

Using markdown-it-vue with nuxtjs #8

Open ewen-lbh opened 5 years ago

ewen-lbh commented 5 years ago

If you are having trouble with a "window is undefined"–type of error while trying to use it with a universal (SSR, Server-side rendered) app, you might want to follow this guide: https://medium.com/@codebeast_/why-your-third-party-plugin-dont-work-in-nuxt-and-how-to-fix-it-d1a8caadf422

It worked like a charm for me

ewen-lbh commented 5 years ago

I know this isn't really an issue but @ravenq you might wanna consider supporting nuxt out-of-the-box

ravenq commented 5 years ago

@ewen-lbh Thanks for you issue!

This package do not supports for SSR yet, because the plugins of charts (echarts, flowchart, memaid.js) do not surpport for SSR.

you can close the ssr option in the nuxt.config.js:

plugins: [
    { src: '@/plugins/markdown-it-vue', ssr: false }
  ],

and make a file in plugins folder, 'markdown-it-vue.js'

import Vue from 'vue'
import MarkdownItVue from 'markdown-it-vue'
import 'markdown-it-vue/dist/markdown-it-vue.css'

Vue.use(MarkdownItVue)

I will try to make it supports for SSR if it can be.

drimacus182 commented 3 years ago

@ravenq Is it possible to create a separate build without all the chart plugins, to use it with nuxt ssr? The same principle as markdown-it-light, I mean.

Personally, I don't need the chart functionality at all, however, it's critical for me to be able to render it with Nuxt SSR

ImSeaWorld commented 3 years ago

@ravenq Is it possible to create a separate build without all the chart plugins, to use it with nuxt ssr? The same principle as markdown-it-light, I mean.

Personally, I don't need the chart functionality at all, however, it's critical for me to be able to render it with Nuxt SSR

Have you tried the Nuxt community module? https://www.npmjs.com/package/@nuxtjs/markdownit

liqinglin0314 commented 5 months ago

@ravenq Can you provide a fully functional version of the SSR framework for Nuxt.js compared to your version? This is very important to me and I need it very much. Thank you. If one day you release this version, please let me know. Thank you! My email is liqinglin0314@aliyun.com