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

Updated for wsaw hub page #1322

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
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
22 changes: 12 additions & 10 deletions blocks/card-list/card-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ import ffetch from '../../scripts/ffetch.js';
import {
ul, a, div, span,
} from '../../scripts/dom-builder.js';

import { getMetadata, toClassName } from '../../scripts/lib-franklin.js';
import createArticleCard from './articleCard.js';
import createLibraryCard from './libraryCard.js';
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 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('topics') > -1) {
if (currentUrl.indexOf(tagName) > -1) {
return currentUrl.substring(0, currentUrl.lastIndexOf('/') + 1) + toClassName(keyword).toLowerCase();
}
return `${currentUrl.replace('.html', '')}/topics/${toClassName(keyword).toLowerCase()}`;
return `${currentUrl.replace('.html', '')}/${tagName}/${toClassName(keyword).toLowerCase()}`;
};

const patchBannerHeading = () => {
Expand Down Expand Up @@ -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[tagName].replace(/,\s*/g, ',').split(','));
const keywords = new Set([].concat(...allKeywords));
keywords.delete('');
keywords.delete('Blog'); // filter out generic blog tag
Expand All @@ -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(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' },
Expand Down Expand Up @@ -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(tagName) > -1) {
patchBannerHeading();
}

Expand All @@ -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'))
Expand All @@ -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[tagName]).toLowerCase().indexOf(activeTagFilter) > -1,
);
}
buildItemListSchema(filteredArticles, 'resources');
Expand Down
3 changes: 2 additions & 1 deletion fstab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
/us/en/library/topics/: /us/en/library/topics-template
/us/en/we-see-a-way/solutions/: /us/en/we-see-a-way
35 changes: 35 additions & 0 deletions helix-query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
4 changes: 4 additions & 0 deletions tools/importer/transformers/cardList.js
Original file line number Diff line number Diff line change
@@ -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)',
Expand Down
Loading