mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 16:17:25 +02:00
fix(v2): only import prism css on browser
This commit is contained in:
parent
f37300a69b
commit
261ab9254d
2 changed files with 8 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Docusaurus webpack loader of [MDX](https://github.com/mdx-js/mdx)
|
Docusaurus webpack loader of [MDX](https://github.com/mdx-js/mdx)
|
||||||
|
|
||||||
The extra idea here is to simplify things by adding prismjs syntax highlighting by default through https://github.com/mapbox/rehype-prism and add the prism css theme import directly.
|
The extra idea here is to simplify things by adding prismjs syntax highlighting by default through https://github.com/mapbox/rehype-prism and add the prism css theme import directly (only add the CSS import if target is 'web').
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
|
@ -27,10 +27,16 @@ module.exports = async function(content) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let importStr = '';
|
||||||
|
// If webpack target is web, we can import the css
|
||||||
|
if (this.target === 'web') {
|
||||||
|
importStr = `import '${options.prismTheme}';`;
|
||||||
|
}
|
||||||
|
|
||||||
const code = `
|
const code = `
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mdx } from '@mdx-js/react';
|
import { mdx } from '@mdx-js/react';
|
||||||
import '${options.prismTheme}';
|
${importStr}
|
||||||
${result}
|
${result}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue