Skip to content

Commit 68f25f5

Browse files
authored
fix(build): duplicate description tags with transformHead (#2702)
1 parent b39b491 commit 68f25f5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/node/build/render.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ export async function renderPage(
158158
: '<meta name="viewport" content="width=device-width,initial-scale=1">'
159159
}
160160
<title>${title}</title>
161-
<meta name="description" content="${description}">
161+
${
162+
isDescriptionOverridden(head)
163+
? ''
164+
: `<meta name="description" content="${description}">`
165+
}
162166
${stylesheetLink}
163167
${metadataScript.inHead ? metadataScript.html : ''}
164168
${
@@ -258,6 +262,12 @@ function filterOutHeadDescription(head: HeadConfig[] = []) {
258262
})
259263
}
260264

265+
function isDescriptionOverridden(head: HeadConfig[] = []) {
266+
return head.some(([type, attrs]) => {
267+
return type === 'meta' && attrs?.name === 'description'
268+
})
269+
}
270+
261271
function isMetaViewportOverridden(head: HeadConfig[] = []) {
262272
return head.some(([type, attrs]) => {
263273
return type === 'meta' && attrs?.name === 'viewport'

0 commit comments

Comments
 (0)