Browse Source

site: Improve code formatting in Previewer component (#40813)

- Remove unnecessary whitespace in the Demo.tsx file
- Replace `<style>` and `</style>` tags with empty strings in the index.css file
- Move the React import statement to the top of the index.js file

[.dumi/theme/builtins/Previewer/index.tsx]
- Remove unnecessary whitespace in the Demo.tsx file
- Replace `<style>` and `</style>` tags with empty strings in the index.css file
- Move the React import statement to the top of the index.js file
- Remove the unnecessary whitespace in the index.js file
pull/40815/head
afc163 2 years ago
committed by GitHub
parent
commit
0bfdff2086
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx

15
.dumi/theme/builtins/Previewer/CodePreviewer.tsx

@ -305,9 +305,9 @@ const CodePreviewer: React.FC<IPreviewerProps> = (props) => {
parsedSourceCode = parsedSourceCode.replace(importReactReg, '').trim();
}
const demoJsContent = `
${importReactContent}
import './index.css';
${parsedSourceCode}
${importReactContent}
import './index.css';
${parsedSourceCode}
`.trim();
const indexCssContent = (style || '')
.trim()
@ -315,12 +315,11 @@ const CodePreviewer: React.FC<IPreviewerProps> = (props) => {
.replace('</style>', '')
.replace('<style>', '');
const indexJsContent = `
import React from 'react';
import { createRoot } from 'react-dom/client';
import Demo from './demo';
const indexJsContent = `import React from 'react';
import { createRoot } from 'react-dom/client';
import Demo from './demo';
createRoot(document.getElementById('container')).render(<Demo />);
createRoot(document.getElementById('container')).render(<Demo />);
`;
const codesandboxPackage = {

Loading…
Cancel
Save