Skip to content

Commit

Permalink
Merge pull request #787 from hlxsites/breadcrumb-fix
Browse files Browse the repository at this point in the history
fix: breadcrumb for template pages
  • Loading branch information
mhaack authored Feb 12, 2024
2 parents a8e30f2 + 9c28463 commit f7ca566
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions blocks/breadcrumb/breadcrumb.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const TEMPLATE_PATH_PATTERN = /\/us\/en\/[^/]+\/topics-template/;

export default function decorate(block) {
const entries = block.querySelector('div > ul');
entries.className = 'max-w-screen-xl w-full mx-auto px-4 flex gap-4 sm:px-6 lg:px-7 overflow-x-auto';
Expand All @@ -15,6 +17,11 @@ export default function decorate(block) {
anchor.setAttribute('tabindex', '-1');
if ((entries.children.length - 1) !== index) element.innerHTML = "<svg class='w-6 h-5/6 flex-shrink-0 text-gray-300' viewBox='0 0 24 44' preserveAspectRatio='none' fill='currentColor' xmlns='http://www.w3.org/2000/svg' aria-hidden='true' data-acsb-hidden='true' data-acsb-force-hidden='true' data-di-rand='1697196048881'><path d='M.293 0l22 22-22 22h1.414l22-22-22-22H.293z'></path></svg>";
element.prepend(anchor);

// special handling for template pages
if (TEMPLATE_PATH_PATTERN.test(anchor.href)) {
anchor.href = anchor.href.replace('topics-template', 'topics');
}
});
const breadcrumbWrapper = block.parentElement;
breadcrumbWrapper.classList.add(...'flex bg-white border-b border-gray-200'.split(' '));
Expand Down

0 comments on commit f7ca566

Please sign in to comment.