Browse Source

docs: add rc-util to top level in codesandbox (#42672)

* fix: tem  modify rc-util@latest in codesandbox

* fix: tem modify rc-util@:^5.32.0 in codesandbox

* fix: add pkgDep info in dumi local pilugin

* chore: rename

---------

Co-authored-by: 洋 <hetongyang@bytedance.com>
pull/42680/head
2 years ago
committed by GitHub
parent
commit
42ff0ea3de
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .dumi/theme/builtins/Previewer/CodePreviewer.tsx
  2. 3
      .dumi/theme/plugin.ts

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

@ -15,6 +15,7 @@ import LZString from 'lz-string';
import Prism from 'prismjs';
import React, { useContext, useEffect, useRef, useState } from 'react';
import CopyToClipboard from 'react-copy-to-clipboard';
import type { AntdPreviewerProps } from '.';
import useLocation from '../../../hooks/useLocation';
import BrowserFrame from '../../common/BrowserFrame';
import ClientOnly from '../../common/ClientOnly';
@ -27,7 +28,6 @@ import RiddleIcon from '../../common/RiddleIcon';
import type { SiteContextProps } from '../../slots/SiteContext';
import SiteContext from '../../slots/SiteContext';
import { ping } from '../../utils';
import type { AntdPreviewerProps } from '.';
const { ErrorBoundary } = Alert;
@ -105,6 +105,7 @@ const CodePreviewer: React.FC<AntdPreviewerProps> = (props) => {
filename,
version,
clientOnly,
pkgDependencyList,
} = props;
const { pkg } = useSiteData();
@ -331,6 +332,7 @@ createRoot(document.getElementById('container')).render(<Demo />);
main: 'index.js',
dependencies: {
...dependencies,
'rc-util': pkgDependencyList['rc-util'],
react: '^18.0.0',
'react-dom': '^18.0.0',
'react-scripts': '^5.0.0',

3
.dumi/theme/plugin.ts

@ -3,6 +3,7 @@ import type { IApi, IRoute } from 'dumi';
import ReactTechStack from 'dumi/dist/techStacks/react';
import fs from 'fs';
import sylvanas from 'sylvanas';
import localPackage from '../../package.json';
/**
* extends dumi internal tech stack, for customize previewer props
@ -18,7 +19,9 @@ class AntdReactTechStack extends ReactTechStack {
const codePath = opts.fileAbsPath!.replace(/\.\w+$/, '.tsx');
const code = fs.existsSync(codePath) ? fs.readFileSync(codePath, 'utf-8') : '';
const pkgDependencyList = localPackage.dependencies;
props.pkgDependencyList = pkgDependencyList;
props.jsx = sylvanas.parseText(code);
if (md) {

Loading…
Cancel
Save