refactor: handle all admonitions via JSX component (#7152)

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
Alexey Pyltsyn 2022-06-03 15:26:33 +03:00 committed by GitHub
parent 17fe43ecc8
commit 5746c58f41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 709 additions and 250 deletions

View file

@ -1,13 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
declare module 'remark-admonitions' {
type Options = {[key: string]: unknown};
const plugin: (options?: Options) => void;
export = plugin;
}

View file

@ -21,7 +21,6 @@ import {
DEFAULT_PLUGIN_ID,
parseMarkdownString,
} from '@docusaurus/utils';
import admonitions from 'remark-admonitions';
import {validatePageFrontMatter} from './frontMatter';
import type {LoadContext, Plugin} from '@docusaurus/types';
@ -43,11 +42,6 @@ export default function pluginContentPages(
context: LoadContext,
options: PluginOptions,
): Plugin<LoadedContent | null> {
if (options.admonitions) {
options.remarkPlugins = options.remarkPlugins.concat([
[admonitions, options.admonitions],
]);
}
const {siteConfig, siteDir, generatedFilesDir, localizationDir} = context;
const contentPaths: PagesContentPaths = {
@ -170,6 +164,7 @@ export default function pluginContentPages(
configureWebpack(config, isServer, {getJSLoader}) {
const {
admonitions,
rehypePlugins,
remarkPlugins,
beforeDefaultRehypePlugins,
@ -194,6 +189,7 @@ export default function pluginContentPages(
{
loader: require.resolve('@docusaurus/mdx-loader'),
options: {
admonitions,
remarkPlugins,
rehypePlugins,
beforeDefaultRehypePlugins,

View file

@ -25,7 +25,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
rehypePlugins: [],
beforeDefaultRehypePlugins: [],
beforeDefaultRemarkPlugins: [],
admonitions: {},
admonitions: true,
};
const PluginOptionSchema = Joi.object<PluginOptions>({

View file

@ -16,7 +16,6 @@ declare module '@docusaurus/plugin-content-pages' {
include: string[];
exclude: string[];
mdxPageComponent: string;
admonitions: {[key: string]: unknown};
};
export type Options = Partial<PluginOptions>;