Skip to content

Instantly share code, notes, and snippets.

@Flaque
Created November 21, 2019 19:16
Show Gist options
  • Save Flaque/a08a4c403f570420e35cba43926b63da to your computer and use it in GitHub Desktop.
Save Flaque/a08a4c403f570420e35cba43926b63da to your computer and use it in GitHub Desktop.
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