From b8ed2e9a8d790c220ce10839a109a530ef50883a Mon Sep 17 00:00:00 2001 From: Megan Thomas Date: Wed, 6 Sep 2023 17:37:13 -0700 Subject: [PATCH] early return --- scripts/utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/utils.js b/scripts/utils.js index d013829..c719153 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -67,7 +67,9 @@ function buildBlock(blockName, content) { } function buildTagsBlock() { - const tagsArray = [...document.head.querySelectorAll('meta[property="article:tag"]')].map((el) => el.content) || []; + const metadata = document.head.querySelectorAll('meta[property="article:tag"]'); + if (!metadata.length) return; + const tagsArray = [...metadata].map((el) => el.content); const tagsBlock = buildBlock('tags', tagsArray.join(', ')); const main = document.querySelector('main'); const recBlock = main.querySelector('.recommended-articles');