mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
test(utils, mdx-loader, core): improve coverage (#6303)
* test(utils, mdx-loader, core): improve coverage * windows... * fix
This commit is contained in:
parent
cf265c051e
commit
a79c23bc45
38 changed files with 841 additions and 219 deletions
|
@ -16,7 +16,7 @@ import type {
|
|||
BlogTags,
|
||||
} from './types';
|
||||
import {
|
||||
parseMarkdownFile,
|
||||
parseMarkdownString,
|
||||
normalizeUrl,
|
||||
aliasedSitePath,
|
||||
getEditUrl,
|
||||
|
@ -104,13 +104,22 @@ function formatBlogPostDate(locale: string, date: Date): string {
|
|||
}
|
||||
|
||||
async function parseBlogPostMarkdownFile(blogSourceAbsolute: string) {
|
||||
const result = await parseMarkdownFile(blogSourceAbsolute, {
|
||||
removeContentTitle: true,
|
||||
});
|
||||
return {
|
||||
...result,
|
||||
frontMatter: validateBlogPostFrontMatter(result.frontMatter),
|
||||
};
|
||||
const markdownString = await fs.readFile(blogSourceAbsolute, 'utf-8');
|
||||
try {
|
||||
const result = parseMarkdownString(markdownString, {
|
||||
removeContentTitle: true,
|
||||
});
|
||||
return {
|
||||
...result,
|
||||
frontMatter: validateBlogPostFrontMatter(result.frontMatter),
|
||||
};
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Error while parsing blog post file ${blogSourceAbsolute}: "${
|
||||
(e as Error).message
|
||||
}".`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const defaultReadingTime: ReadingTimeFunction = ({content, options}) =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue