mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
feat(v2): various markdown string parsing improvements/fixes (#4590)
* extract createExcerpt code in separate file + add bad test * almost working markdown parsing refactor * complete parseMarkdownString refactor * fix tests * fix blog test issue * fix docusaurus utils imports
This commit is contained in:
parent
b743edf5fb
commit
4efe6824b3
15 changed files with 895 additions and 563 deletions
|
@ -9,7 +9,10 @@ const {getOptions} = require('loader-utils');
|
|||
const {readFile} = require('fs-extra');
|
||||
const mdx = require('@mdx-js/mdx');
|
||||
const emoji = require('remark-emoji');
|
||||
const {readFrontMatter} = require('@docusaurus/utils');
|
||||
const {
|
||||
parseFrontMatter,
|
||||
parseMarkdownContentTitle,
|
||||
} = require('@docusaurus/utils');
|
||||
const stringifyObject = require('stringify-object');
|
||||
const headings = require('./remark/headings');
|
||||
const toc = require('./remark/toc');
|
||||
|
@ -26,12 +29,14 @@ module.exports = async function docusaurusMdxLoader(fileString) {
|
|||
const callback = this.async();
|
||||
const reqOptions = getOptions(this) || {};
|
||||
|
||||
const {frontMatter, content, hasFrontMatter} = readFrontMatter(
|
||||
fileString,
|
||||
this.resourcePath,
|
||||
{},
|
||||
reqOptions.removeTitleHeading,
|
||||
);
|
||||
const {frontMatter, content: contentWithTitle} = parseFrontMatter(fileString);
|
||||
|
||||
// By default, will remove the markdown title from the content
|
||||
const {content} = parseMarkdownContentTitle(contentWithTitle, {
|
||||
keepContentTitle: reqOptions.keepContentTitle,
|
||||
});
|
||||
|
||||
const hasFrontMatter = Object.keys(frontMatter).length > 0;
|
||||
|
||||
const options = {
|
||||
...reqOptions,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue