mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 16:17:25 +02:00
feat: add own webpack markdown to react loader
This commit is contained in:
parent
2a7f7e2663
commit
10f85696d9
1 changed files with 19 additions and 0 deletions
19
lib/webpack/loader/markdown.js
Normal file
19
lib/webpack/loader/markdown.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const {getOptions} = require('loader-utils');
|
||||
const fm = require('front-matter');
|
||||
// const MarkdownBlock = require('../../core/components/markdown');
|
||||
|
||||
module.exports = function(fileString) {
|
||||
const options = getOptions(this);
|
||||
|
||||
const {body} = fm(fileString);
|
||||
const source = JSON.stringify(body);
|
||||
const siteConfig = JSON.stringify(options.siteConfig);
|
||||
|
||||
return (
|
||||
`import React from 'react';\n` +
|
||||
`import MarkdownBlock from '@core/components/Markdown'\n` +
|
||||
`export default () => <MarkdownBlock source={${source}} siteConfig={${siteConfig}} />;`
|
||||
);
|
||||
|
||||
// return `export default () => <MarkdownBlock source={${source}} siteConfig={${siteConfig}} />`;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue