mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-11 15:22:29 +02:00
feat(mdx-loader): Remark plugin to report unused MDX / Markdown directives (#9394)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
56cc8e8ffa
commit
c6762a2542
19 changed files with 506 additions and 26 deletions
|
@ -15,8 +15,10 @@ import details from './remark/details';
|
|||
import head from './remark/head';
|
||||
import mermaid from './remark/mermaid';
|
||||
import transformAdmonitions from './remark/admonitions';
|
||||
import unusedDirectivesWarning from './remark/unusedDirectives';
|
||||
import codeCompatPlugin from './remark/mdx1Compat/codeCompatPlugin';
|
||||
import {getFormat} from './format';
|
||||
import type {WebpackCompilerName} from '@docusaurus/utils';
|
||||
import type {MDXFrontMatter} from './frontMatter';
|
||||
import type {Options} from './loader';
|
||||
import type {AdmonitionOptions} from './remark/admonitions';
|
||||
|
@ -37,10 +39,12 @@ type SimpleProcessor = {
|
|||
content,
|
||||
filePath,
|
||||
frontMatter,
|
||||
compilerName,
|
||||
}: {
|
||||
content: string;
|
||||
filePath: string;
|
||||
frontMatter: {[key: string]: unknown};
|
||||
compilerName: WebpackCompilerName;
|
||||
}) => Promise<SimpleProcessorResult>;
|
||||
};
|
||||
|
||||
|
@ -123,6 +127,7 @@ async function createProcessorFactory() {
|
|||
gfm,
|
||||
options.markdownConfig.mdx1Compat.comments ? comment : null,
|
||||
...(options.remarkPlugins ?? []),
|
||||
unusedDirectivesWarning,
|
||||
].filter((plugin): plugin is MDXPlugin => Boolean(plugin));
|
||||
|
||||
// codeCompatPlugin needs to be applied last after user-provided plugins
|
||||
|
@ -167,12 +172,13 @@ async function createProcessorFactory() {
|
|||
});
|
||||
|
||||
return {
|
||||
process: async ({content, filePath, frontMatter}) => {
|
||||
process: async ({content, filePath, frontMatter, compilerName}) => {
|
||||
const vfile = new VFile({
|
||||
value: content,
|
||||
path: filePath,
|
||||
data: {
|
||||
frontMatter,
|
||||
compilerName,
|
||||
},
|
||||
});
|
||||
return mdxProcessor.process(vfile).then((result) => ({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue