Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: breadcrumb for template pages #787

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading