rsnext/examples/with-netlify-cms/next.config.js

32 lines
723 B
JavaScript
Raw Normal View History

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