Created
November 21, 2019 19:16
-
-
Save Flaque/a08a4c403f570420e35cba43926b63da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const getPathsForArticles = () => | |
fs | |
.readdirSync("./content/articles") | |
.map(blogName => { | |
const trimmedName = blogName.substring(0, blogName.length - 3); | |
return { | |
[`/${trimmedName}`]: { | |
page: "/[slug]", | |
query: { | |
slug: trimmedName | |
} | |
} | |
}; | |
}) | |
.reduce((acc, curr) => ({ ...acc, ...curr }), {}); | |
const MaxsConfig = { | |
webpack: configuration => { | |
configuration.module.rules.push({ | |
test: /\.md$/, | |
use: "frontmatter-markdown-loader" | |
}); | |
return configuration; | |
}, | |
async exportPathMap(defaultPathMap) { | |
return { | |
...defaultPathMap, | |
...getPathsForArticles() | |
}; | |
}, | |
poweredByHeader: false | |
}; | |
function myPlugin(nextConfig) { | |
return Object.assign({}, nextConfig, MaxsConfig) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment