@@ -99,13 +99,14 @@ const generateUnformattedCode = (
99
99
// route links are only a next.js feature. if the user creates a rotue link and then switches projects, generate code for a normal link instead
100
100
else if ( child . type === 'Route Link' ) {
101
101
return projectType === 'Next.js'
102
- ? `<Link href="/${ child . name } "><a>${ child . name } </a></Link>`
103
- : `<a>${ child . name } </a>` ;
102
+ ? `<div>< Link href="/${ child . name } "><a>${ child . name } </a></Link></div >`
103
+ : `<div>< a>${ child . name } </a></div >` ;
104
104
}
105
105
} )
106
106
. join ( '\n' ) } `;
107
107
} ;
108
108
109
+ // format styles stored in object to match React's inline style format
109
110
const formatStyles = ( styleObj : any ) => {
110
111
if ( Object . keys ( styleObj ) . length === 0 ) return `` ;
111
112
const formattedStyles = [ ] ;
@@ -194,9 +195,13 @@ const generateUnformattedCode = (
194
195
195
196
return (
196
197
<>
197
- <Head>
198
+ ${
199
+ isRoot
200
+ ? `<Head>
198
201
<title>${ currentComponent . name } </title>
199
- </Head>
202
+ </Head>`
203
+ : ``
204
+ }
200
205
<div className="${ currentComponent . name } " style={props.style}>
201
206
${ writeNestedElements ( enrichedChildren ) }
202
207
</div>
@@ -212,13 +217,6 @@ const generateUnformattedCode = (
212
217
// formats code with prettier linter
213
218
const formatCode = ( code : string ) => {
214
219
return window . api . formatCode ( code ) ;
215
- // return format(code, {
216
- // singleQuote: true,
217
- // trailingComma: 'es5',
218
- // bracketSpacing: true,
219
- // jsxBracketSameLine: true,
220
- // parser: 'babel'
221
- // });
222
220
} ;
223
221
224
222
// generate code based on component heirarchy and then return the rendered code
0 commit comments