@rcdoc/vitejs-plugin
A plugin enables you to import a Markdown file as various formats on your [vite](https://github.com/vitejs/vite) project inspirt by [dumi](https://github.com/umijs/dumi).
Last updated 8 months ago by sanlang .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @rcdoc/vitejs-plugin 
SYNC missed versions from official npm registry.

vite-plugin-mdoc

mdoc for vite

A plugin enables you to import a Markdown file as various formats on your vite project inspirt by dumi.

Setup

npm i -D vite-plugin-react-mdoc

Config

const mdoc = require('vite-plugin-react-mdoc');

module.exports = {
  plugins: [mdoc(options)],
};

Then you can import front matter attributes from .md file as default.

# Hello world

```tsx
import React from 'react';

export default () => {
  const [count, setCount] = React.useState(0);
  return <button onClick={() => setCount((v) => v + 1)}>count: {count}</button>;
};
```
import { MdContent, demos } from './doc.md';

Type declarations

In TypeScript project, need to declare typedefs for .md file as you need.

declare module '*.md' {
  // When "Mode.React" is requested. VFC could take a generic like React.VFC<{ MyComponent: TypeOfMyComponent }>
  import React from 'react';
  type MDocPreviewerProps = {
    code: string;
    lang: string;
    key: string;
    dependencies: Record<
      string,
      {
        type: string;
        value: string;
        css: boolean;
      }
    >;
    meta: Record<string, any>;
    children: React.ReactNode;
  };

  const MdContent: React.VFC<{
    previewer?: (props: MDocPreviewerProps) => React.ReactNode;
  }>;
  const demos: ({ Component: React.VFC; key: string } & Record<string, any>)[];

  const frontmatter: Record<string, string>;

  const slugs: { depth: number; text: string; id: string }[];

  const filePath: string;

  // Modify below per your usage
  export { MdContent, demos, frontmatter, slugs, filePath };
}

Save as vite.d.ts for instance.

License

MIT

Current Tags

  • 0.2.2                                ...           latest (8 months ago)

15 Versions

  • 0.2.2                                ...           8 months ago
  • 0.2.1                                ...           8 months ago
  • 0.2.0                                ...           9 months ago
  • 0.1.10                                ...           9 months ago
  • 0.1.9                                ...           9 months ago
  • 0.1.8                                ...           2 years ago
  • 0.1.7                                ...           2 years ago
  • 0.1.6                                ...           3 years ago
  • 0.1.5                                ...           3 years ago
  • 0.1.4                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.0-dev.1                                ...           3 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE