From 4a4ba793855dccfef7b4fab41ca46cc299a0d79b Mon Sep 17 00:00:00 2001 From: Markus Haack <mhaack@adobe.com> Date: Wed, 7 Feb 2024 16:26:40 +0100 Subject: [PATCH 1/3] fix: url generation --- blocks/card-list/card-list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blocks/card-list/card-list.js b/blocks/card-list/card-list.js index b6038f68e..5848e5693 100644 --- a/blocks/card-list/card-list.js +++ b/blocks/card-list/card-list.js @@ -9,14 +9,14 @@ import createApplicationCard from './applicationCard.js'; import createLibraryCard from './libraryCard.js'; import { makePublicUrl } from '../../scripts/scripts.js'; -const getSelectionFromUrl = () => (window.location.pathname.indexOf('topics') > -1 ? toClassName(window.location.pathname.split('/').pop()) : ''); +const getSelectionFromUrl = () => (window.location.pathname.indexOf('topics') > -1 ? toClassName(window.location.pathname.replace('.html', '').split('/').pop()) : ''); const getPageFromUrl = () => toClassName(new URLSearchParams(window.location.search).get('page')) || ''; const createTopicUrl = (keyword = '') => { if (window.location.pathname.indexOf('topics') > -1) { return window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1) + toClassName(keyword).toLowerCase(); } - return `${window.location.pathname}/topics/${toClassName(keyword).toLowerCase()}`; + return `${window.location.pathname.replace('.html', '')}/topics/${toClassName(keyword).toLowerCase()}`; }; const createPaginationLink = (page, label, current = false) => { From 9d138a105cef20cbec5dab576ab6f1a451b5a2b3 Mon Sep 17 00:00:00 2001 From: Markus Haack <mhaack@adobe.com> Date: Wed, 7 Feb 2024 16:54:48 +0100 Subject: [PATCH 2/3] chore: converter for news page & heading --- blocks/card-list/card-list.js | 15 ++++++++++++--- tools/importer/transformers/cardList.js | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/blocks/card-list/card-list.js b/blocks/card-list/card-list.js index 5848e5693..3f1cf3c1c 100644 --- a/blocks/card-list/card-list.js +++ b/blocks/card-list/card-list.js @@ -1,9 +1,9 @@ import ffetch from '../../scripts/ffetch.js'; import { - ul, a, div, span, h2, + ul, a, div, span, h2, i, } from '../../scripts/dom-builder.js'; -import { toClassName } from '../../scripts/lib-franklin.js'; +import { getMetadata, toClassName } from '../../scripts/lib-franklin.js'; import createArticleCard from './articleCard.js'; import createApplicationCard from './applicationCard.js'; import createLibraryCard from './libraryCard.js'; @@ -19,6 +19,10 @@ const createTopicUrl = (keyword = '') => { return `${window.location.pathname.replace('.html', '')}/topics/${toClassName(keyword).toLowerCase()}`; }; +const patchBannerHeading = () => { + document.querySelector('body .banner h1').textContent = getMetadata('heading'); +}; + const createPaginationLink = (page, label, current = false) => { const newUrl = new URL(window.location); newUrl.searchParams.set('page', page); @@ -119,6 +123,12 @@ const createFilters = (articles, activeTag) => { } tags.append(tagAnchor); }); + + // patch banner heading with selected tag only on topics pages + if (getMetadata('heading') && window.location.pathname.indexOf('topics') > -1) { + patchBannerHeading(); + } + return tags; }; @@ -203,7 +213,6 @@ export default async function decorate(block) { // render pagination and filters const filterTags = createFilters(articles, activeTagFilter); const paginationElements = createPagination(filteredArticles, page, limitPerPage); - block.append(filterTags, cardList, paginationElements); } } diff --git a/tools/importer/transformers/cardList.js b/tools/importer/transformers/cardList.js index c53215d7b..a729c2e92 100644 --- a/tools/importer/transformers/cardList.js +++ b/tools/importer/transformers/cardList.js @@ -12,6 +12,10 @@ const URLS_TO_BLOCK_MAP = [ url: '/news.html', blockName: 'Card List (news)', }, + { + url: '/news/topics-template.html', + blockName: 'Card List (news, url-filtered)', + }, { url: '/application.html', blockName: 'Card List (application)', From b41d2b82d478b1ede1bc588264eaf04898887480 Mon Sep 17 00:00:00 2001 From: Markus Haack <mhaack@adobe.com> Date: Wed, 7 Feb 2024 16:58:36 +0100 Subject: [PATCH 3/3] fix: lint issues --- blocks/card-list/card-list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/card-list/card-list.js b/blocks/card-list/card-list.js index 3f1cf3c1c..453bf68ef 100644 --- a/blocks/card-list/card-list.js +++ b/blocks/card-list/card-list.js @@ -1,6 +1,6 @@ import ffetch from '../../scripts/ffetch.js'; import { - ul, a, div, span, h2, i, + ul, a, div, span, h2, } from '../../scripts/dom-builder.js'; import { getMetadata, toClassName } from '../../scripts/lib-franklin.js';