From 7ab4eb37b5decec630819b35b6a724619eee6906 Mon Sep 17 00:00:00 2001 From: Bryan Deffley Date: Fri, 14 Jun 2024 09:54:36 -0400 Subject: [PATCH] refactor function --- cigaradvisor/scripts/linking-data.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cigaradvisor/scripts/linking-data.js b/cigaradvisor/scripts/linking-data.js index ea6dfea..24e2172 100644 --- a/cigaradvisor/scripts/linking-data.js +++ b/cigaradvisor/scripts/linking-data.js @@ -127,14 +127,16 @@ function addFAQLdJson() { } export default function addLinkingData() { - const category = getCategory(window.location.pathname); addOrg(document.querySelector('head')); if (window.location.pathname === '/cigaradvisor') { addBlogPosts(); - } else if (window.location.pathname === category) { - addOrUpdateCollection(); - window.addEventListener('hashchange', addOrUpdateCollection); - } else if (category) { - addFAQLdJson(); + } else { + const category = getCategory(window.location.pathname); + if (window.location.pathname === category) { + addOrUpdateCollection(); + window.addEventListener('hashchange', addOrUpdateCollection); + } else if (category) { + addFAQLdJson(); + } } }