Skip to content

Import markdown files in your Next.js project

Notifications You must be signed in to change notification settings

alexblunck/next-md

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Import markdown files in your Next.js project

Resources

Stars

Watchers

Forks

Packages

No packages published