Skip to content

Commit

Permalink
Update article-teaser.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kailasnadh790 committed Dec 5, 2023
1 parent 8b202b2 commit d5b3c02
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cigaradvisor/blocks/article-teaser/article-teaser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ async function fetchData(url) {
}

export default async function decorate(block) {
const filters = readBlockConfig(block);
let doc;
const filterPath = block.querySelector('a').getAttribute('href');
block.textContent = '';
block.classList.add('article-teaser');
const url = new URL(filters.path);
const trimmedURL = url.pathname;
const fetchUrl = `${window.hlx.codeBasePath}/drafts/Kailas/pagemeta.json`;
const teaserContent = await fetchData(fetchUrl);
const articleInfo = teaserContent.find((obj) => obj.path === trimmedURL);
const articleInfo = teaserContent.find((obj) => obj.path === filterPath);
const categoryListUrl = `${window.hlx.codeBasePath}/drafts/Kailas/category/category-list.json`;
const categoryListData = await fetchData(categoryListUrl);
const articlePath = articleInfo.path;
Expand All @@ -46,7 +43,7 @@ export default async function decorate(block) {
.then((html) => {
// Create a new HTML document using DOMParser
const parser = new DOMParser();
doc = parser.parseFromString(html, 'text/html');
const doc = parser.parseFromString(html, 'text/html');
const articleCategory = getMetadata('category', doc);
const articleCategoryInfo = categoryListData.find((obj) => obj.category === articleCategory);
const articleCategoryLink = articleCategoryInfo.categoryLink;
Expand Down

0 comments on commit d5b3c02

Please sign in to comment.