Skip to content

Commit c1a9043

Browse files
fix: superfluous title tag from react-helmet-async #23
1 parent 3f786ea commit c1a9043

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

examples/single-page/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5+
<title>Vite + React</title>
56
</head>
67
<body>
78
<div id="root"></div>

src/node/server.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ function extractHelmet(context: FilledContext, styleCollector: StyleCollector |
6262
const { helmet } = context
6363
const htmlAttributes = helmet.htmlAttributes.toString()
6464
const bodyAttributes = helmet.bodyAttributes.toString()
65+
let titleString = helmet.title.toString()
66+
if (titleString.split('>')[1] === '</title') {
67+
titleString = ''
68+
}
6569
const metaStrings = [
66-
helmet.title.toString(),
70+
titleString,
6771
helmet.meta.toString(),
6872
helmet.link.toString(),
6973
helmet.script.toString(),

0 commit comments

Comments
 (0)