fix(build): duplicate description tags with transformHead (#2702)

pull/2705/head
Divyansh Singh 1 year ago committed by GitHub
parent b39b4912af
commit 68f25f5a9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -158,7 +158,11 @@ export async function renderPage(
: '<meta name="viewport" content="width=device-width,initial-scale=1">' : '<meta name="viewport" content="width=device-width,initial-scale=1">'
} }
<title>${title}</title> <title>${title}</title>
<meta name="description" content="${description}"> ${
isDescriptionOverridden(head)
? ''
: `<meta name="description" content="${description}">`
}
${stylesheetLink} ${stylesheetLink}
${metadataScript.inHead ? metadataScript.html : ''} ${metadataScript.inHead ? metadataScript.html : ''}
${ ${
@ -258,6 +262,12 @@ function filterOutHeadDescription(head: HeadConfig[] = []) {
}) })
} }
function isDescriptionOverridden(head: HeadConfig[] = []) {
return head.some(([type, attrs]) => {
return type === 'meta' && attrs?.name === 'description'
})
}
function isMetaViewportOverridden(head: HeadConfig[] = []) { function isMetaViewportOverridden(head: HeadConfig[] = []) {
return head.some(([type, attrs]) => { return head.some(([type, attrs]) => {
return type === 'meta' && attrs?.name === 'viewport' return type === 'meta' && attrs?.name === 'viewport'

Loading…
Cancel
Save