Code Monkey home page Code Monkey logo

vite-plugin-vue3-mdx's Introduction

vite-plugin-vue3-mdx

NPM version

Warning

This plugin is not well tested, if you come to any bug, please feel free to report the issue! Meanwhile, you should be aware of the risk of using this plugin!

Installation

pnpm i -D vite-plugin-vue3-mdx
// vite.config.ts
import { defineConfig } from 'vite'
import mdx from 'vite-plugin-vue3-mdx'
import vueJsx from '@vitejs/plugin-vue-jsx'

export default defineConfig({
  plugins: [
    vueJsx({ include: [/\.[jt]sx$/, /\.mdx?$/] }),
    mdx(),
  ]
})

Extensions

export default defineConfig({
  plugins: [
    // ...
    mdx({
      rehypePlugins: [rehypePrism], // any rehype plugins
      recmaPlugins: [], // any recma plugins
      remarkPlugins: [], // any remark plugins
    }),
  ]
})

For full type declarations, find them in types.

License

MIT License © 2022 widcardw

vite-plugin-vue3-mdx's People

Contributors

widcardw avatar

Watchers

 avatar

vite-plugin-vue3-mdx's Issues

Vue Jsx cannot mount Layout component

The docs of mdx reveal that I can export a custom layout with the expressions:

export default function Layout({children}) {
  return <main>{children}</main>;
}

And the compiler gets the output

/*@jsxRuntime automatic @jsxImportSource react*/
const MDXLayout = function ({children}) {
  return <main>{children}</main>;
};
function _createMdxContent(props) {
  const _components = Object.assign({
    h1: "h1"
  }, props.components);
  return <_components.h1>{"hi"}</_components.h1>;
}
function MDXContent(props = {}) {
  return <MDXLayout {...props}><_createMdxContent {...props} /></MDXLayout>;
}
export default MDXContent;

However, vue cannot mount the _createMdxContent component. It will ignore the child.

<main>
  <!---->
</main>

As is known to us, we should use <slot> to insert the children component, just like

const MDXLayout = () => {
  return <div class="..."><slot /></div>
}

So how can I solve this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.