hmsk/vite-plugin-markdown

Can I use it without react or vue?

xsf0105 opened this issue · 2 comments

Can I use it without react or vue? I just want to use it in a simple application with vite and html + js + css.
I have tried it, but got error:

image

vite.config.js is:

import { defineConfig } from 'vite';
import path from "path";
import mdPlugin, { Mode }  from "vite-plugin-markdown"

const { resolve } = path;

export default defineConfig({
  server: {
    port: 2023,
    host: "0.0.0.0",
  },
  resolve: {
  alias: [
    { find: "@", replacement: resolve(__dirname, "./src") },
  ],
  },
  plugins: [
    mdPlugin.plugin({ mode: [Mode.HTML, Mode.MARKDOWN, Mode.TOC] })
  ],
})

mypage.tsx:

import Hello, { attributes } from "./defining.md"

console.log(Hello, attributes, 11);
VmMad commented

you need to import what you want like this:
import { html as DefiningText, toc as DefiningTOC } from "./defining.md"

thanks bro, another question:

defining.md code as following:

image

image

How to make the code highlight?