Import markdown files in your Next.js project
npm install --save @blunck/next-md
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 }} />
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()
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
}
})