@politico/markdown-react-loader

    0.0.3 • Public • Published

    POLITICO

    @politico/markdown-react-loader

    Loads markdown files for use as React components.

    Install

    $ yarn add -D @politico/markdown-react-loader react-markdown
    

    Use

    Add to your Webpack config.

    module.exports = {
      module: {
        loaders: [
          {
            test: /\.md$/,
            loader: '@politico/markdown-react-loader'
          }
        ]
      }
    }

    Import and use markdown files.

    import Text from 'text.md';
    
    const MyComponent = () => (
      <div>
        <Text />
      </div>
    );

    You can pass any valid props that you would otherwise pass to react-markdown.

    <Text linkTarget='_blank' />

    The loader also preprocesses the text of your markdown files through mustache.js, so you can also pass a context object to your component and add mustache's templating syntax to make your markdown even more powerful.

    This is my **{{ mood }}** markdown file.
    <Text context={{ mood: 'AWESOME' }} />

    Test

    $ yarn start
    

    Development

    Make it better, then:

    $ npm publish --access public
    

    Keywords

    none

    Install

    npm i @politico/markdown-react-loader

    DownloadsWeekly Downloads

    2

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    257 kB

    Total Files

    8

    Last publish

    Collaborators

    • mshushan-politico
    • kherbert
    • pfriedr
    • arm5077
    • wickidd
    • stilessl
    • guirreri
    • mazet
    • brizandrew
    • bzjin