Skip to content

Commit 4d69609

Browse files
committed
Resolved Next.js page title bug
1 parent 5a60fec commit 4d69609

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

app/src/helperFunctions/generateCode.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ const generateUnformattedCode = (
9999
// 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
100100
else if (child.type === 'Route Link') {
101101
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>`;
104104
}
105105
})
106106
.join('\n')}`;
107107
};
108108

109+
// format styles stored in object to match React's inline style format
109110
const formatStyles = (styleObj: any) => {
110111
if (Object.keys(styleObj).length === 0) return ``;
111112
const formattedStyles = [];
@@ -194,9 +195,13 @@ const generateUnformattedCode = (
194195
195196
return (
196197
<>
197-
<Head>
198+
${
199+
isRoot
200+
? `<Head>
198201
<title>${currentComponent.name}</title>
199-
</Head>
202+
</Head>`
203+
: ``
204+
}
200205
<div className="${currentComponent.name}" style={props.style}>
201206
${writeNestedElements(enrichedChildren)}
202207
</div>
@@ -212,13 +217,6 @@ const generateUnformattedCode = (
212217
// formats code with prettier linter
213218
const formatCode = (code: string) => {
214219
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-
// });
222220
};
223221

224222
// generate code based on component heirarchy and then return the rendered code

0 commit comments

Comments
 (0)