feat(v2): allow passing remark, rehype, prismtheme to mdx-loader (#1543)

* feat(v2): allow passing remark, rehype, prismtheme to mdx-loader

* nits
This commit is contained in:
Endi 2019-06-03 14:54:27 +07:00 committed by GitHub
parent 6a814ac64a
commit 8743ee5041
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 10 deletions

View file

@ -25,9 +25,20 @@ module.exports = async function(fileString) {
const callback = this.async();
const {data, content} = matter(fileString);
const options = Object.assign(DEFAULT_OPTIONS, getOptions(this), {
const reqOptions = getOptions(this) || {};
const options = {
...reqOptions,
remarkPlugins: [
...DEFAULT_OPTIONS.remarkPlugins,
...(reqOptions.remarkPlugins || []),
],
rehypePlugins: [
...DEFAULT_OPTIONS.rehypePlugins,
...(reqOptions.rehypePlugins || []),
],
prismTheme: reqOptions.prismTheme || DEFAULT_OPTIONS.prismTheme,
filepath: this.resourcePath,
});
};
let result;
try {