mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
26 lines
774 B
TypeScript
26 lines
774 B
TypeScript
/**
|
|
* 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.
|
|
*/
|
|
|
|
import visit from 'unist-util-visit';
|
|
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
|
|
import type {Transformer} from 'unified';
|
|
|
|
// @ts-expect-error: ES support...
|
|
import type {MdxJsxFlowElement} from 'mdast-util-mdx';
|
|
|
|
// Transform <head> to <Head>
|
|
// MDX 2 doesn't allow to substitute html elements with the provider anymore
|
|
export default function plugin(): Transformer {
|
|
return (root) => {
|
|
visit(root, 'mdxJsxFlowElement', (node: MdxJsxFlowElement) => {
|
|
if (node.name === 'head') {
|
|
node.name = 'Head';
|
|
}
|
|
});
|
|
};
|
|
}
|