1.0.0 • Published 6 years ago

@blunck/next-md v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

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
    }
})