From 4f849b37474a65e8649f8e73fe4344aa89278b70 Mon Sep 17 00:00:00 2001 From: rgravitvl Date: Wed, 11 Dec 2024 10:32:56 +0530 Subject: [PATCH 1/2] Updated for wsaw hub page --- blocks/card-list/card-list.js | 20 +++++++------- fstab.yaml | 3 ++- helix-query.yaml | 35 +++++++++++++++++++++++++ tools/importer/transformers/cardList.js | 4 +++ 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/blocks/card-list/card-list.js b/blocks/card-list/card-list.js index 61ea21b5d..aeff120c5 100644 --- a/blocks/card-list/card-list.js +++ b/blocks/card-list/card-list.js @@ -3,6 +3,7 @@ import { ul, a, div, span, } from '../../scripts/dom-builder.js'; +let tag = getMetadata('template') === 'wsaw' ? 'solutions' : 'topics'; import { getMetadata, toClassName } from '../../scripts/lib-franklin.js'; import createArticleCard from './articleCard.js'; import createLibraryCard from './libraryCard.js'; @@ -10,14 +11,14 @@ import createApplicationCard from './applicationCard.js'; import { makePublicUrl } from '../../scripts/scripts.js'; import { buildItemListSchema } from '../../scripts/schema.js'; -const getSelectionFromUrl = () => (window.location.pathname.indexOf('topics') > -1 ? toClassName(window.location.pathname.replace('.html', '').split('/').pop()) : ''); +const getSelectionFromUrl = () => (window.location.pathname.indexOf(tag) > -1 ? toClassName(window.location.pathname.replace('.html', '').split('/').pop()) : ''); const getPageFromUrl = () => toClassName(new URLSearchParams(window.location.search).get('page')) || ''; const createTopicUrl = (currentUrl, keyword = '') => { - if (currentUrl.indexOf('topics') > -1) { + if (currentUrl.indexOf(tag) > -1) { return currentUrl.substring(0, currentUrl.lastIndexOf('/') + 1) + toClassName(keyword).toLowerCase(); } - return `${currentUrl.replace('.html', '')}/topics/${toClassName(keyword).toLowerCase()}`; + return `${currentUrl.replace('.html', '')}/${tag}/${toClassName(keyword).toLowerCase()}`; }; const patchBannerHeading = () => { @@ -83,7 +84,7 @@ const createPagination = (entries, page, limit) => { export function createFilters(articles, viewAll = false) { // collect tag filters - const allKeywords = articles.map((item) => item.topics.replace(/,\s*/g, ',').split(',')); + const allKeywords = articles.map((item) => item[tag].replace(/,\s*/g, ',').split(',')); const keywords = new Set([].concat(...allKeywords)); keywords.delete(''); keywords.delete('Blog'); // filter out generic blog tag @@ -92,8 +93,8 @@ export function createFilters(articles, viewAll = false) { // render tag cloud const newUrl = new URL(window.location); newUrl.searchParams.delete('page'); - if (window.location.pathname.indexOf('topics') > -1) { - newUrl.pathname = window.location.pathname.substring(0, window.location.pathname.indexOf('/topics/')); + if (window.location.pathname.indexOf(tag) > -1) { + newUrl.pathname = window.location.pathname.substring(0, window.location.pathname.indexOf(`/${tag}/`)); } const tags = viewAll ? div( { class: 'flex flex-wrap gap-2 gap-y-0 mb-4' }, @@ -138,7 +139,7 @@ export function createFilters(articles, viewAll = false) { }); // patch banner heading with selected tag only on topics pages - if (getMetadata('heading') && window.location.pathname.indexOf('topics') > -1) { + if (getMetadata('heading') && window.location.pathname.indexOf(tag) > -1) { patchBannerHeading(); } @@ -150,8 +151,9 @@ export default async function decorate(block) { if (articleType) block.classList.remove(articleType); block.textContent = ''; + const indexType = getMetadata('template') === 'wsaw' ? 'wsaw' : 'article'; // fetch and sort all articles - const articles = await ffetch('/us/en/article-index.json') + const articles = await ffetch(`/us/en/${indexType}-index.json`) .chunks(500) .filter(({ type }) => type.toLowerCase() === articleType) .filter((article) => !article.path.includes('/topics-template')) @@ -160,7 +162,7 @@ export default async function decorate(block) { const activeTagFilter = block.classList.contains('url-filtered') ? getSelectionFromUrl() : ''; if (activeTagFilter) { filteredArticles = articles.filter( - (item) => toClassName(item.topics).toLowerCase().indexOf(activeTagFilter) > -1, + (item) => toClassName(item[tag]).toLowerCase().indexOf(activeTagFilter) > -1, ); } buildItemListSchema(filteredArticles, 'resources'); diff --git a/fstab.yaml b/fstab.yaml index 8ee702fd4..639ab0f34 100644 --- a/fstab.yaml +++ b/fstab.yaml @@ -10,4 +10,5 @@ folders: /us/en/products/bundles/: /us/en/products/product-coveo /us/en/blog/topics/: /us/en/blog/topics-template /us/en/news/topics/: /us/en/news/topics-template - /us/en/library/topics/: /us/en/library/topics-template \ No newline at end of file + /us/en/library/topics/: /us/en/library/topics-template + /us/en/we-see-a-way/solutions/: /us/en/we-see-a-way \ No newline at end of file diff --git a/helix-query.yaml b/helix-query.yaml index 46d3b0b23..ce55588f2 100644 --- a/helix-query.yaml +++ b/helix-query.yaml @@ -27,6 +27,9 @@ indices: topics: select: head > meta[name="topics"] value: attribute(el, "content") + solutions: + select: head > meta[name="solutions"] + value: attribute(el, "content") readingTime: select: head > meta[name="readingtime"] value: attribute(el, "content") @@ -79,3 +82,35 @@ indices: solution: select: head > meta[name="solution"] value: attribute(el, "content") + wsaw: + include: + - /us/en/we-see-a-way/** + target: /us/en/wsaw-index.json + properties: + lastModified: + select: none + value: parseTimestamp(headers["last-modified"], "ddd, DD MMM YYYY hh:mm:ss GMT") + title: + select: main h1 + value: textContent(el) + navTitle: + select: head > meta[name="navtitle"] + value: attribute(el, "content") + description: + select: head > meta[name="description"] + value: attribute(el, "content") + image: + select: head > meta[property="og:image"] + value: match(attribute(el, "content"), "^(https?:\/\/.*?(danaher.com))+(.*)|^(.*)") + solutions: + select: head > meta[name="solutions"] + value: attribute(el, "content") + publishDate: + select: head > meta[name="publishdate"] + value: parseTimestamp(attribute(el, "content"), "ddd, DD MMM YYYY hh:mm:ss GMT") + type: + select: head > meta[name="template"] + value: attribute(el, "content") + brand: + select: head > meta[name="brand"] + value: attribute(el, "content") \ No newline at end of file diff --git a/tools/importer/transformers/cardList.js b/tools/importer/transformers/cardList.js index f3e72895d..605e9eadd 100644 --- a/tools/importer/transformers/cardList.js +++ b/tools/importer/transformers/cardList.js @@ -1,5 +1,9 @@ /* global WebImporter */ const URLS_TO_BLOCK_MAP = [ + { + url: '/we-see-a-way.html', + blockName: 'Card List (wsaw)', + }, { url: '/blog.html', blockName: 'Card List (blog)', From 04b8f2ddb32f2aa43e901bf1067cc253e3b5bf25 Mon Sep 17 00:00:00 2001 From: rgravitvl Date: Wed, 11 Dec 2024 10:42:08 +0530 Subject: [PATCH 2/2] Fixed lint issues --- blocks/card-list/card-list.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/blocks/card-list/card-list.js b/blocks/card-list/card-list.js index aeff120c5..df9860b8e 100644 --- a/blocks/card-list/card-list.js +++ b/blocks/card-list/card-list.js @@ -2,8 +2,6 @@ import ffetch from '../../scripts/ffetch.js'; import { ul, a, div, span, } from '../../scripts/dom-builder.js'; - -let tag = getMetadata('template') === 'wsaw' ? 'solutions' : 'topics'; import { getMetadata, toClassName } from '../../scripts/lib-franklin.js'; import createArticleCard from './articleCard.js'; import createLibraryCard from './libraryCard.js'; @@ -11,14 +9,16 @@ import createApplicationCard from './applicationCard.js'; import { makePublicUrl } from '../../scripts/scripts.js'; import { buildItemListSchema } from '../../scripts/schema.js'; -const getSelectionFromUrl = () => (window.location.pathname.indexOf(tag) > -1 ? toClassName(window.location.pathname.replace('.html', '').split('/').pop()) : ''); +const tagName = getMetadata('template') === 'wsaw' ? 'solutions' : 'topics'; + +const getSelectionFromUrl = () => (window.location.pathname.indexOf(tagName) > -1 ? toClassName(window.location.pathname.replace('.html', '').split('/').pop()) : ''); const getPageFromUrl = () => toClassName(new URLSearchParams(window.location.search).get('page')) || ''; const createTopicUrl = (currentUrl, keyword = '') => { - if (currentUrl.indexOf(tag) > -1) { + if (currentUrl.indexOf(tagName) > -1) { return currentUrl.substring(0, currentUrl.lastIndexOf('/') + 1) + toClassName(keyword).toLowerCase(); } - return `${currentUrl.replace('.html', '')}/${tag}/${toClassName(keyword).toLowerCase()}`; + return `${currentUrl.replace('.html', '')}/${tagName}/${toClassName(keyword).toLowerCase()}`; }; const patchBannerHeading = () => { @@ -84,7 +84,7 @@ const createPagination = (entries, page, limit) => { export function createFilters(articles, viewAll = false) { // collect tag filters - const allKeywords = articles.map((item) => item[tag].replace(/,\s*/g, ',').split(',')); + const allKeywords = articles.map((item) => item[tagName].replace(/,\s*/g, ',').split(',')); const keywords = new Set([].concat(...allKeywords)); keywords.delete(''); keywords.delete('Blog'); // filter out generic blog tag @@ -93,8 +93,8 @@ export function createFilters(articles, viewAll = false) { // render tag cloud const newUrl = new URL(window.location); newUrl.searchParams.delete('page'); - if (window.location.pathname.indexOf(tag) > -1) { - newUrl.pathname = window.location.pathname.substring(0, window.location.pathname.indexOf(`/${tag}/`)); + if (window.location.pathname.indexOf(tagName) > -1) { + newUrl.pathname = window.location.pathname.substring(0, window.location.pathname.indexOf(`/${tagName}/`)); } const tags = viewAll ? div( { class: 'flex flex-wrap gap-2 gap-y-0 mb-4' }, @@ -139,7 +139,7 @@ export function createFilters(articles, viewAll = false) { }); // patch banner heading with selected tag only on topics pages - if (getMetadata('heading') && window.location.pathname.indexOf(tag) > -1) { + if (getMetadata('heading') && window.location.pathname.indexOf(tagName) > -1) { patchBannerHeading(); } @@ -162,7 +162,7 @@ export default async function decorate(block) { const activeTagFilter = block.classList.contains('url-filtered') ? getSelectionFromUrl() : ''; if (activeTagFilter) { filteredArticles = articles.filter( - (item) => toClassName(item[tag]).toLowerCase().indexOf(activeTagFilter) > -1, + (item) => toClassName(item[tagName]).toLowerCase().indexOf(activeTagFilter) > -1, ); } buildItemListSchema(filteredArticles, 'resources');