Skip to content

Commit

Permalink
fixes the circular link issue which was caused due to using query loops
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukhtar Mukhtar committed Feb 23, 2024
1 parent 1b096f8 commit 88f9b62
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pages/_includes/statewide-footer.njk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,53 @@
document
.querySelector('.js-cagov-current-year')
.innerHTML = new Date().getFullYear();
// 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);
}
}
});
}
</script>&nbsp;{{ 'State of California' | i18n(locale) }}
</p>
</div>
Expand Down

0 comments on commit 88f9b62

Please sign in to comment.