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 {
type TagsListItem,
type TagModule,
} from '@docusaurus/utils';
import admonitions from 'remark-admonitions';
import {
generateBlogPosts,
getSourceToPermalink,
@ -49,12 +48,6 @@ export default async function pluginContentBlog(
context: LoadContext,
options: PluginOptions,
): Promise<Plugin<BlogContent>> {
if (options.admonitions) {
options.remarkPlugins = options.remarkPlugins.concat([
[admonitions, options.admonitions],
]);
}
const {
siteDir,
siteConfig,
@ -381,6 +374,7 @@ export default async function pluginContentBlog(
configureWebpack(_config, isServer, {getJSLoader}, content) {
const {
admonitions,
rehypePlugins,
remarkPlugins,
truncateMarker,
@ -423,6 +417,7 @@ export default async function pluginContentBlog(
{
loader: require.resolve('@docusaurus/mdx-loader'),
options: {
admonitions,
remarkPlugins,
rehypePlugins,
beforeDefaultRemarkPlugins: [

View file

@ -24,7 +24,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
feedOptions: {type: ['rss', 'atom'], copyright: ''},
beforeDefaultRehypePlugins: [],
beforeDefaultRemarkPlugins: [],
admonitions: {},
admonitions: true,
truncateMarker: /<!--\s*truncate\s*-->/,
rehypePlugins: [],
remarkPlugins: [],

View file

@ -377,7 +377,6 @@ declare module '@docusaurus/plugin-content-blog' {
* unlocalized file. Ignored when `editUrl` is a function.
*/
editLocalizedFiles?: boolean;
admonitions: {[key: string]: unknown};
/** Path to the authors map file, relative to the blog content directory. */
authorsMapPath: string;
/** A callback to customize the reading time number displayed. */