rsnext/examples/with-netlify-cms/next.config.js
Józef Piecyk d94d2700f9 Netlify cms example (#8949)
* add netlifycms example

* Updated everything

* Moved the layout out of _app

* Updated next to latest

* applied prettier and linter

* Removed unrequired files

* Moved to with-netlify-cms

* updated readme to reflect the new name

* Added license field
2019-10-19 18:46:49 -05:00

31 lines
723 B
JavaScript

const fs = require('fs')
const blogPostsFolder = './content/blogPosts'
const getPathsForPosts = () =>
fs.readdirSync(blogPostsFolder).reduce((acc, blogName) => {
const trimmedName = blogName.substring(0, blogName.length - 3)
return Object.assign(acc, {
[`/blog/post/${trimmedName}`]: {
page: '/blog/post/[slug]',
query: {
slug: trimmedName
}
}
})
}, {})
module.exports = {
webpack: configuration => {
configuration.module.rules.push({
test: /\.md$/,
use: 'frontmatter-markdown-loader'
})
return configuration
},
async exportPathMap (defaultPathMap) {
return {
...defaultPathMap,
...getPathsForPosts()
}
}
}