From 68f25f5a9cca1d059831184ad8876bb40326d9b6 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Fri, 28 Jul 2023 23:25:51 +0530 Subject: [PATCH] fix(build): duplicate description tags with transformHead (#2702) --- src/node/build/render.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/node/build/render.ts b/src/node/build/render.ts index a3079903..8a283b90 100644 --- a/src/node/build/render.ts +++ b/src/node/build/render.ts @@ -158,7 +158,11 @@ export async function renderPage( : '' } ${title} - + ${ + isDescriptionOverridden(head) + ? '' + : `` + } ${stylesheetLink} ${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[] = []) { return head.some(([type, attrs]) => { return type === 'meta' && attrs?.name === 'viewport'