mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-26 04:57:50 +02:00
refactor(mdx-loader): re-export metadata module instead of serializing it (#10470)
This commit is contained in:
parent
3d69ff3d47
commit
a47e8dda2d
6 changed files with 33 additions and 145 deletions
|
@ -5,7 +5,6 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import logger from '@docusaurus/logger';
|
||||
import {escapePath, type WebpackCompilerName} from '@docusaurus/utils';
|
||||
import {getProcessor, type SimpleProcessorResult} from './processor';
|
||||
|
@ -13,23 +12,6 @@ import {validateMDXFrontMatter} from './frontMatter';
|
|||
import preprocessor from './preprocessor';
|
||||
import type {Options} from './loader';
|
||||
|
||||
/**
|
||||
* When this throws, it generally means that there's no metadata file associated
|
||||
* with this MDX document. It can happen when using MDX partials (usually
|
||||
* starting with _). That's why it's important to provide the `isMDXPartial`
|
||||
* function in config
|
||||
*/
|
||||
export async function readMetadataPath(metadataPath: string): Promise<unknown> {
|
||||
try {
|
||||
return await fs.readJSON(metadataPath, 'utf8');
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
logger.interpolate`MDX loader can't read MDX metadata file path=${metadataPath}. Maybe the isMDXPartial option function was not provided?`,
|
||||
{cause: error as Error},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts assets an object with Webpack require calls code.
|
||||
* This is useful for mdx files to reference co-located assets using relative
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue