File tree Expand file tree Collapse file tree 5 files changed +45
-5
lines changed Expand file tree Collapse file tree 5 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export default function renderDemo(md, container) {
25
25
const [ , demoPath , componentName = '' ] = match ;
26
26
const demoPathOnlyLetters = demoPath . replace ( / [ ^ a - z A - Z \d ] / g, '' ) ;
27
27
const demoName = path . basename ( demoPath ) . trim ( ) ;
28
- const demoDefName = `Demo${ demoPathOnlyLetters } ` ;
28
+ const demoDefName = `Demo${ demoPathOnlyLetters } Component ` ;
29
29
const demoCodeDefName = `Demo${ demoPathOnlyLetters } Code` ;
30
30
31
31
const tpl = `
@@ -34,7 +34,7 @@ export default function renderDemo(md, container) {
34
34
35
35
</div>
36
36
<div className="tdesign-demo-item__body">
37
- <div style={{width: '100%'}}>< ${ demoDefName } /> </div>
37
+ <div style={{width: '100%'}}>{ ${ demoDefName } } </div>
38
38
</div>
39
39
</td-doc-demo>
40
40
` ;
Original file line number Diff line number Diff line change @@ -31,15 +31,16 @@ function getGitTimestamp(file) {
31
31
32
32
export default async function mdToReact ( options ) {
33
33
const mdSegment = await customRender ( options ) ;
34
- const { demoDefsStr, demoCodesDefsStr } = options ;
34
+ const { demoDefsStr, demoCodesDefsStr, components } = options ;
35
35
36
36
const reactSource = `
37
- import { h } from 'omi';
37
+ import { h, define } from 'omi';
38
38
import { signal, effect } from 'reactive-signal'
39
39
import Prismjs from 'prismjs';
40
40
import 'prismjs/components/prism-bash.js';
41
41
${ demoDefsStr }
42
42
${ demoCodesDefsStr }
43
+ ${ components }
43
44
44
45
export default function TdDoc() {
45
46
const isComponent = ${ mdSegment . isComponent } ;
Original file line number Diff line number Diff line change @@ -44,12 +44,27 @@ export default {
44
44
. map ( ( key ) => demoCodesImports [ key ] )
45
45
. join ( '\n' ) ;
46
46
47
+ const components = Object . keys ( demoImports )
48
+ . map (
49
+ ( key ) => `
50
+ let ${ key } Component = null;
51
+ if('${ key } '.endsWith('omi')){
52
+ define('t-${ key . toLocaleLowerCase ( ) } ', ${ key } );
53
+ ${ key } Component = <t-${ key . toLocaleLowerCase ( ) } />;
54
+ } else {
55
+ ${ key } Component = <${ key } />;
56
+ };
57
+ ` ,
58
+ )
59
+ . join ( '\n' ) ;
60
+
47
61
const sfc = mdToWc ( {
48
62
md,
49
63
file,
50
64
source,
51
65
demoDefsStr,
52
66
demoCodesDefsStr,
67
+ components,
53
68
} ) ;
54
69
return sfc ;
55
70
} ,
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ spline: base
8
8
9
9
### 基础使用
10
10
11
- {{ base }}
11
+ {{ base-omi }}
12
12
13
13
### 图标按钮
14
14
Original file line number Diff line number Diff line change
1
+ import 'tdesign-web-components/button' ;
2
+
3
+ import { Component } from 'omi' ;
4
+
5
+ export default class Button extends Component {
6
+ render ( ) {
7
+ return (
8
+ < div style = { { gap : 16 , display : 'inline-flex' } } >
9
+ < t-button theme = "default" variant = "base" >
10
+ 填充按钮
11
+ </ t-button >
12
+ < t-button theme = "default" variant = "outline" >
13
+ 描边按钮
14
+ </ t-button >
15
+ < t-button theme = "default" variant = "dashed" >
16
+ 虚框按钮
17
+ </ t-button >
18
+ < t-button theme = "default" variant = "text" >
19
+ 文字按钮
20
+ </ t-button >
21
+ </ div >
22
+ ) ;
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments