项目作者: markdown-doc

项目描述 :
A React backend for markdown-doc-loader
高级语言: JavaScript
项目地址: git://github.com/markdown-doc/react-markdown-doc-loader.git
创建时间: 2017-05-08T03:54:53Z
项目社区:https://github.com/markdown-doc/react-markdown-doc-loader

开源协议:

下载


react-markdown-doc-loader

A webpack loader to convert markdown-doc-loader‘s output to React component.

markdown-doc-loader converts a markdown file to a list of sections. There’re three
types of section: markdown, style and demo.

Usage

Use as a webpack loader

  1. {
  2. module: {
  3. rules: [
  4. {
  5. test: /\.md$/,
  6. use: [
  7. 'babel-loader',
  8. {
  9. loader: require.resolve('react-markdown-doc-loader'),
  10. options: {
  11. jsTemplate: path.join(__dirname, './react-template.js'),
  12. renderers: {
  13. markdown: 'Markdown',
  14. style: 'Style',
  15. demo: 'Demo'
  16. }
  17. }
  18. }
  19. 'markdown-doc-loader'
  20. ]
  21. }
  22. ]
  23. }
  24. }

Options

  • jsTemplate: path to js template file, uses babel-template.
  • renderers: a map of component names to different types of sections

Available properties in the template:

  • SECTIONS: All sections in the file, style, demo and markdown.
    Styles are compiled to css with precss
    demos are code fragments that return a React node
    markdowns are compiled to html

  • IMPORTS: All imports from demos

  • DEMO_DECLARATIONS: Declarations for demos

Take a look at sample/template.js.