diff --git a/blocks/page-tabs/page-tabs.js b/blocks/page-tabs/page-tabs.js index 86b1ebbb..e7410c85 100644 --- a/blocks/page-tabs/page-tabs.js +++ b/blocks/page-tabs/page-tabs.js @@ -102,6 +102,10 @@ function hasSpecifications(productResponse) { return productResponse?.raw?.numattributes > 0; } +function hasOverview(productResponse) { + return productResponse?.raw?.richlongdescription; +} + export default async function decorate(block) { const response = await getProductResponse(); let productResponse; @@ -157,11 +161,24 @@ export default async function decorate(block) { return hasProducts(productResponse); case 'product-details': return hasParts(productResponse); + case 'overview': + return hasOverview(productResponse); default: return true; } }); + // Check if 'overview' tab exists + const hasOverviewTab = filteredTabs.some((tab) => tab.id === 'overview'); + + // Set currentTab to 'overview' if it exists, otherwise 'specifications' + currentTab = hasOverviewTab ? 'overview' : 'specifications'; + + // If 'overview' tab does not exist, reload the page with '#specifications' in the URL + if (!hasOverviewTab) { + window.location.hash = '#specifications'; + } + const navList = createTabList(filteredTabs, currentTab); // For Mobile View diff --git a/tools/importer/transformers/cardList.js b/tools/importer/transformers/cardList.js index b311b377..e888086c 100644 --- a/tools/importer/transformers/cardList.js +++ b/tools/importer/transformers/cardList.js @@ -41,6 +41,7 @@ const URLS_TO_BLOCK_MAP = [ const createCardList = (main, document) => { const url = document.querySelector('[property="og:url"]')?.content; if (url) { + // eslint-disable-next-line max-len const blockName = URLS_TO_BLOCK_MAP.find((item) => url.endsWith(item.url) || url.includes(item.url))?.blockName; if (blockName) { const block = [[blockName], ['']];