@@ -153,9 +153,30 @@ export class StackblitzWriter {
153153 fileContent = fileContent . replace ( / { { version} } / g, VERSION . full ) ;
154154 } else if ( fileName == 'main.ts' ) {
155155 // Replace the component name in `main.ts`.
156- // For example, `import {MaterialDocsExample} from 'material-docs-example'`
156+ // Replace `import {MaterialDocsExample} from 'material-docs-example'`
157157 // will be replaced as `import {ButtonDemo} from './button-demo'`
158- fileContent = fileContent . replace ( / M a t e r i a l D o c s E x a m p l e / g, data . componentName ) ;
158+ fileContent = fileContent . replace ( / { M a t e r i a l D o c s E x a m p l e } / g, `{${ data . componentName } }` ) ;
159+
160+ // Replace `declarations: [MaterialDocsExample]`
161+ // will be replaced as `declarations: [ButtonDemo]`
162+ fileContent = fileContent .
163+ replace ( / d e c l a r a t i o n s : \[ M a t e r i a l D o c s E x a m p l e \] / g,
164+ `declarations: [${ data . componentName } ]` ) ;
165+
166+ // Replace `entryComponents: [MaterialDocsExample]`
167+ // will be replaced as `entryComponents: [DialogContent]`
168+ fileContent = fileContent .
169+ replace ( / e n t r y C o m p o n e n t s : \[ M a t e r i a l D o c s E x a m p l e \] / g,
170+ `entryComponents: [${ data . componentName } ]` ) ;
171+
172+ // Replace `bootstrap: [MaterialDocsExample]`
173+ // will be replaced as `bootstrap: [ButtonDemo]`
174+ // This assumes the first component listed in the main component
175+ const componentList = data . componentName . split ( ',' ) [ 0 ] ;
176+ fileContent = fileContent .
177+ replace ( / b o o t s t r a p : \[ M a t e r i a l D o c s E x a m p l e \] / g,
178+ `bootstrap: [${ componentList } ]` ) ;
179+
159180 fileContent = fileContent . replace ( / m a t e r i a l - d o c s - e x a m p l e / g, data . indexFilename ) ;
160181 }
161182 return fileContent ;
0 commit comments