Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 1.17 KB

README.md

File metadata and controls

59 lines (44 loc) · 1.17 KB

Next.js + Markdown

Import markdown files in your Next.js project

Installation

npm install --save @blunck/next-md

Usage

Create a next.config.js in your project

// next.config.js
const withMarkdown = require('@blunck/next-md')()
module.exports = withMarkdown()

You can now import parsed strings from .md files

import foo from './foo.md'

export default () => <div dangerouslySetInnerHTML={{ __html: foo }} />

With markdown-loader and html-loader options

Optionally you can provide Marked.js and html-loader options

// next.config.js
const withMarkdown = require('@blunck/next-md')({
    markdownLoaderOptions: {
        gfm: true
    },
    htmlLoaderOptions: {
        minimize: true,
        conservativeCollapse: false
    }
})
module.exports = withMarkdown()

Configuring Next.js

Optionally you can add your custom Next.js configuration as parameter

// next.config.js
const withMarkdown = require('@blunck/next-md')()
module.exports = withMarkdown({
    webpack(config, options) {
        return config
    }
})