Skip to content

Commit

Permalink
Fixed lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rgravitvl committed Dec 11, 2024
1 parent 4f849b3 commit 04b8f2d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions blocks/card-list/card-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ 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';
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 = () => {
Expand Down Expand Up @@ -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
Expand All @@ -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' },
Expand Down Expand Up @@ -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();
}

Expand All @@ -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');
Expand Down

0 comments on commit 04b8f2d

Please sign in to comment.