0.3.1 • Published 3 years ago

umi-plugin-md v0.3.1

Weekly downloads
5
License
MIT
Repository
-
Last release
3 years ago

umi-plugin-md · GitHub license npm version npm downloads PRs Welcome

Markdown(*.md) component plugin for umi.

Create your website with umi and markdown only. Convenient and powerful for blog, documentation site and GitBook.

  • Convert markdown into component: loaded by markdown-it and translate into React component.
  • Auto routes create: auto create markdown routes from dir.
  • Auto anchor: auto create anchor for h1, h2 and h3.
  • XSS protect: by xss.
  • Support: umi@2.x only

Example

Installation

npm install umi-plugin-md

Demo

https://chiaweilee.github.io/umi-plugin-md/

Usage

// .umirc.js
export default {
  plugins: ['umi-plugin-md'],
};

Options

optionintrotypedefault
anchorAuto Anchor ^0.2.0string[], falsy to disable'h1', 'h2', 'h3'
wrapperHTMLElementTagNamestringsection
classNameReact classNamestring
styleReact styleobject
htmlmarkdown-it optionbooleantrue
xhtmlOutmarkdown-it optionbooleantrue
breaksmarkdown-it optionbooleantrue
linkifymarkdown-it optionbooleantrue
typographermarkdown-it optionbooleantrue
highlightmarkdown-it optionfunctionhighlight.js
renderwrapper render(rawHtml: string) => string;see src/render.ts

tips: route of markdown will have higher priority, so route might be covered.

e.g, index.md will cover index.jsx.

Anchor

Example

Get anchor id?

import { slug } from 'umi-plugin-md';

var text = $('h2').text();
var id = slug(text);

Or copy umi-plugin-md/lib/helpers/slug.js to your repo.

Anchor Stylize

// global.css
@import "~umi-plugin-md/anchor.css";

Or, write yourself.

tips: we do not support scroll to anchor on 'componentDidMount' this moment.

Markdown Stylize

github-markdown-css

// global.css
@import "~github-markdown-css/github-markdown.css";
@import "~highlight.js/styles/github.css";
// .umirc.js
export default {
  plugins: [['umi-plugin-md', { className: 'markdown-body' }]],
};

Priority

index.md have higher priority than index.jsx.

0.3.0

3 years ago

0.3.1

3 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0-beta.1

5 years ago

0.0.0-beta.12

5 years ago

0.0.0-beta.11

5 years ago

0.0.0-beta.10

5 years ago

0.0.0-beta.9

5 years ago

0.0.0-beta.8

5 years ago

0.0.0-beta.7

5 years ago

0.0.0-beta.6

5 years ago

0.0.0-beta.5

5 years ago

0.0.0-beta.3

5 years ago

0.0.0-beta.2

5 years ago

0.0.0-beta.1

5 years ago