mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 16:47:26 +02:00
refactor(v2): shift to docusaurus/mdx-loader (#1339)
This commit is contained in:
parent
1a8e12048e
commit
aa27f82acc
8 changed files with 179 additions and 40 deletions
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
const fm = require('front-matter');
|
||||
const mdx = require('@mdx-js/mdx');
|
||||
const {getOptions} = require('loader-utils');
|
||||
const path = require('path');
|
||||
const {resolve} = require('url');
|
||||
|
@ -74,25 +73,5 @@ module.exports = async function(fileString) {
|
|||
content = lines.join('\n');
|
||||
}
|
||||
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = await mdx(content, options);
|
||||
} catch (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
// TODO: Allow choosing prismjs theme
|
||||
// prismjs/themes/XXXXXX.css https://github.com/PrismJS/prism/tree/master/themes
|
||||
// prism-themes/themes/XXXXXX.css https://github.com/PrismJS/prism-themes/tree/master/themes
|
||||
const prismThemeImport = 'prism-themes/themes/prism-atom-dark.css';
|
||||
|
||||
const code = `
|
||||
import React from 'react';
|
||||
import { MDXTag } from '@mdx-js/tag';
|
||||
import '${prismThemeImport}';
|
||||
${result}
|
||||
`;
|
||||
|
||||
return callback(null, code);
|
||||
return callback(null, content);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue