d94d2700f9
* 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
31 lines
723 B
JavaScript
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()
|
|
}
|
|
}
|
|
}
|