From 4c3d94f62e7b5a9a47883a5fa8bd89ba9a49d394 Mon Sep 17 00:00:00 2001 From: Mukhtar Mukhtar <‘mukkhtarr@gmail.com’> Date: Thu, 22 Feb 2024 17:29:04 -0800 Subject: [PATCH] removes circular link issue which was caused by query loops --- pages/_includes/statewide-footer.njk | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/pages/_includes/statewide-footer.njk b/pages/_includes/statewide-footer.njk index 2251c8d6a84..ca8f99e9296 100644 --- a/pages/_includes/statewide-footer.njk +++ b/pages/_includes/statewide-footer.njk @@ -52,6 +52,55 @@ document .querySelector('.js-cagov-current-year') .innerHTML = new Date().getFullYear(); + //Start Circular Links Removal - by Mukhtar + // Get the current pathname + +var currentPathname = window.location.pathname; + + + +// Find the div element with the class 'wp-block-query' + +var queryDiv = document.querySelector('.wp-block-query'); + + + +if (queryDiv) { + + // Find all the 'li' elements within the 'div' + + var listItems = queryDiv.querySelectorAll('li'); + + + + // Loop through the 'li' elements + + listItems.forEach(function (li) { + + var link = li.querySelector('a'); // Assuming 'a' elements contain the href + + if (link) { + + var href = link.getAttribute('href'); + + + + // Check if the href matches the current pathname + + if (href.includes(currentPathname)) { + + // Remove the 'li' element if the href matches + + li.parentNode.removeChild(li); + + } + + } + + }); + +} + //End Circular Links Removal  {{ 'State of California' | i18n(locale) }}