fix: type error in mdx defaults

This commit is contained in:
bholmesdev 2023-03-06 11:47:00 -05:00
parent 4226b03579
commit 5fce7a2819
2 changed files with 12 additions and 6 deletions

View file

@ -66,11 +66,11 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): Integr
});
const extendMarkdownConfig =
partialMdxOptions.extendMarkdownConfig ?? defaultOptions.extendMarkdownConfig;
partialMdxOptions.extendMarkdownConfig ?? defaultMdxOptions.extendMarkdownConfig;
const mdxOptions = applyDefaultOptions({
options: partialMdxOptions,
defaults: extendMarkdownConfig ? config.markdown : defaultOptions,
defaults: withDefaultMdxOptions(extendMarkdownConfig ? config.markdown : markdownConfigDefaults),
});
const mdxPluginOpts: MdxRollupPluginOptions = {
@ -185,14 +185,20 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): Integr
};
}
const defaultOptions: MdxOptions = {
...markdownConfigDefaults,
const defaultMdxOptions = {
extendMarkdownConfig: true,
recmaPlugins: [],
remarkPlugins: [],
rehypePlugins: [],
remarkRehype: {},
}
function withDefaultMdxOptions(markdownConfig: typeof markdownConfigDefaults): MdxOptions {
return {
...markdownConfig,
...defaultMdxOptions,
};
}
function applyDefaultOptions({
options,

View file

@ -179,7 +179,7 @@ export function getRehypePlugins(mdxOptions: MdxOptions): MdxRollupPluginOptions
return rehypePlugins;
}
function ignoreStringPlugins(plugins: any[]) {
function ignoreStringPlugins(plugins: any[]): PluggableList {
let validPlugins: PluggableList = [];
let hasInvalidPlugin = false;
for (const plugin of plugins) {