mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 10:52:35 +02:00
feat(v2): add beforeDefaultRemarkPlugins/beforeDefaultRehypePlugins options to all md content plugins (#3467)
* fix(plugin-content-docs): add beforeDefaultRemarkPlugins + beforeDefaultRehypePlugins options * fix(plugin-content-blog): add beforeDefaultRemarkPlugins + beforeDefaultRehypePlugins options * fix(plugin-content-pages): add beforeDefaultRemarkPlugins + beforeDefaultRehypePlugins options * feat(website-docs): overriding remark-rehype plugins * fix(plugin-content): update beforeDefaultRehypePlugins/beforeDefaultRemarkPlugins types * fix(plugin-content-docs): fix tests
This commit is contained in:
parent
f343450e85
commit
d3a01458a3
10 changed files with 57 additions and 3 deletions
|
@ -161,7 +161,12 @@ export default function pluginContentPages(
|
|||
isServer: boolean,
|
||||
{getBabelLoader, getCacheLoader}: ConfigureWebpackUtils,
|
||||
) {
|
||||
const {rehypePlugins, remarkPlugins} = options;
|
||||
const {
|
||||
rehypePlugins,
|
||||
remarkPlugins,
|
||||
beforeDefaultRehypePlugins,
|
||||
beforeDefaultRemarkPlugins,
|
||||
} = options;
|
||||
return {
|
||||
resolve: {
|
||||
alias: {
|
||||
|
@ -181,6 +186,8 @@ export default function pluginContentPages(
|
|||
options: {
|
||||
remarkPlugins,
|
||||
rehypePlugins,
|
||||
beforeDefaultRehypePlugins,
|
||||
beforeDefaultRemarkPlugins,
|
||||
staticDir: path.join(siteDir, STATIC_DIR_NAME),
|
||||
// Note that metadataPath must be the same/in-sync as
|
||||
// the path from createData for each MDX.
|
||||
|
|
|
@ -19,6 +19,8 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|||
mdxPageComponent: '@theme/MDXPage',
|
||||
remarkPlugins: [],
|
||||
rehypePlugins: [],
|
||||
beforeDefaultRehypePlugins: [],
|
||||
beforeDefaultRemarkPlugins: [],
|
||||
admonitions: {},
|
||||
exclude: [
|
||||
'**/_*.{js,jsx,ts,tsx,md,mdx}',
|
||||
|
@ -35,5 +37,11 @@ export const PluginOptionSchema = Joi.object({
|
|||
mdxPageComponent: Joi.string().default(DEFAULT_OPTIONS.mdxPageComponent),
|
||||
remarkPlugins: RemarkPluginsSchema.default(DEFAULT_OPTIONS.remarkPlugins),
|
||||
rehypePlugins: RehypePluginsSchema.default(DEFAULT_OPTIONS.rehypePlugins),
|
||||
beforeDefaultRehypePlugins: RehypePluginsSchema.default(
|
||||
DEFAULT_OPTIONS.beforeDefaultRehypePlugins,
|
||||
),
|
||||
beforeDefaultRemarkPlugins: RemarkPluginsSchema.default(
|
||||
DEFAULT_OPTIONS.beforeDefaultRemarkPlugins,
|
||||
),
|
||||
admonitions: AdmonitionsSchema.default(DEFAULT_OPTIONS.admonitions),
|
||||
});
|
||||
|
|
|
@ -14,6 +14,8 @@ export interface PluginOptions {
|
|||
mdxPageComponent: string;
|
||||
remarkPlugins: ([Function, object] | Function)[];
|
||||
rehypePlugins: string[];
|
||||
beforeDefaultRemarkPlugins: ([Function, object] | Function)[];
|
||||
beforeDefaultRehypePlugins: ([Function, object] | Function)[];
|
||||
admonitions: any;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue