diff --git a/blocks/breadcrumbs/breadcrumbs.css b/blocks/breadcrumbs/breadcrumbs.css index 951a0a97b..9954956fe 100644 --- a/blocks/breadcrumbs/breadcrumbs.css +++ b/blocks/breadcrumbs/breadcrumbs.css @@ -6,8 +6,8 @@ } .news main .breadcrumbs, -.publication main .breadcrumbs, -.events main .breadcrumbs { +.events main .breadcrumbs, +.publication:not(.full-article) main .breadcrumbs { padding-top: 70px; } diff --git a/blocks/card-list-filter/card-list-filter.js b/blocks/card-list-filter/card-list-filter.js index 7c8a9b3be..3e7fbff47 100644 --- a/blocks/card-list-filter/card-list-filter.js +++ b/blocks/card-list-filter/card-list-filter.js @@ -43,9 +43,7 @@ function scrollBlockIntoView(block) { left: 0, behavior: 'smooth', }); - }, - 1000, - ); + }, 1000); } }); }); diff --git a/blocks/card-list/card-list.js b/blocks/card-list/card-list.js index 5cc49a892..254bdb055 100644 --- a/blocks/card-list/card-list.js +++ b/blocks/card-list/card-list.js @@ -246,22 +246,33 @@ const VARIANTS = { cardRenderer: blogCardRender, async getData() { - return ffetch('/query-index.json') + let data = []; + const publications = await ffetch('/query-index.json') + .sheet('publications') + .filter((resource) => resource.publicationType === 'Full Article') + .all(); + + const blogs = await ffetch('/query-index.json') .sheet('blog') .all(); - }, - getCategories(item) { - const category = item.path - .split('/')[2]; + data = [...publications, ...blogs]; - if (!category || category === 'blog') return null; + data.sort((x, y) => { + if (x.date > y.date) { + return -1; + } + if (x.date < y.date) { + return 1; + } + return 0; + }); - const filterableCategory = category.split('-') - .map((s) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase()) - .join('-'); + return data; + }, - return [filterableCategory]; + getCategories(item) { + return [item.category || item.Category]; }, }, diff --git a/scripts/scripts.js b/scripts/scripts.js index 06c142a6c..e2da13c04 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -792,27 +792,57 @@ async function formInModalHandler(main) { /* ============================ scrollToHashSection ============================ */ function scrollToHashSection() { - const hashInterval = setTimeout(() => { - const activeHash = window.location.hash; - if (activeHash) { - const id = activeHash.substring(1, activeHash.length).toLocaleLowerCase(); - const targetElement = document.getElementById(id); - if (targetElement) { - window.scrollTo({ - left: 0, - top: targetElement.offsetTop - 250, - behavior: 'smooth', - }); + const observerTarget = document.body; + const observer = new MutationObserver((mutations) => { + mutations.forEach(() => { + const activeHash = window.location.hash; + if (activeHash) { + const id = activeHash.substring(1).toLowerCase(); + const targetElement = document.getElementById(id); + if (targetElement) { + window.scrollTo({ + top: targetElement.offsetTop - 250, + behavior: 'smooth', + }); + observer.disconnect(); + } } - clearInterval(hashInterval); - } - }, 1000); + }); + }); + + observer.observe(observerTarget, { childList: true, subtree: true, attributes: true }); } window.addEventListener('load', scrollToHashSection); -window.addEventListener('hashchange', scrollToHashSection); +// window.addEventListener('hashchange', scrollToHashSection); /* ============================ scrollToHashSection ============================ */ +/** + * Detect anchor + */ +export function detectAnchor(block) { + const activeHash = window.location.hash; + if (!activeHash) return; + + const id = activeHash.substring(1, activeHash.length).toLocaleLowerCase(); + const el = block.querySelector(`#${id}`); + if (el) { + const observer = new MutationObserver((mutationList) => { + mutationList.forEach((mutation) => { + if (mutation.type === 'attributes' + && mutation.attributeName === 'data-block-status' + && block.attributes.getNamedItem('data-block-status').value === 'loaded') { + observer.disconnect(); + setTimeout(() => { + window.dispatchEvent(new Event('hashchange')); + }, 3500); + } + }); + }); + observer.observe(block, { attributes: true }); + } +} + /** * Decorates the main element. * @param {Element} main The main element @@ -1155,32 +1185,6 @@ export function getCartItemCount() { return getCookie('cart-item-count') || 0; } -/** - * Detect anchor - */ -export function detectAnchor(block) { - const activeHash = window.location.hash; - if (!activeHash) return; - - const id = activeHash.substring(1, activeHash.length).toLocaleLowerCase(); - const el = block.querySelector(`#${id}`); - if (el) { - const observer = new MutationObserver((mutationList) => { - mutationList.forEach((mutation) => { - if (mutation.type === 'attributes' - && mutation.attributeName === 'data-block-status' - && block.attributes.getNamedItem('data-block-status').value === 'loaded') { - observer.disconnect(); - setTimeout(() => { - window.dispatchEvent(new Event('hashchange')); - }, 3500); - } - }); - }); - observer.observe(block, { attributes: true }); - } -} - async function loadPage() { await window.hlx.plugins.load('eager'); await loadEager(document);