Skip to content

Commit

Permalink
article-list
Browse files Browse the repository at this point in the history
  • Loading branch information
kailasnadh790 committed Jan 19, 2024
1 parent 9131cfd commit 5c2a3e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
28 changes: 23 additions & 5 deletions cigaradvisor/blocks/article-list/article-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,34 @@ import { buildArticleTeaser } from '../article-teaser/article-teaser.js';
export default async function decorate(block) {
const configs = readBlockConfig(block);
const { category } = configs;
const parentDiv = document.createElement('div');
parentDiv.classList.add('section');
parentDiv.dataset.layout = '50/50';
const leftDiv = document.createElement('div');
leftDiv.classList.add('left-grid');
const rightDiv = document.createElement('div');
rightDiv.classList.add('right-grid');
let current = rightDiv;
if (category) {
const articles = await fetchData(getRelativePath(category), '/cigaradvisor/posts/query-index.json', 'category');
if (!articles || articles.length === 0) {
return;
}
const articlesList = document.createElement('div');
articlesList.classList.add('article-teaser-list');
[...articles].map(async (article) => {
await buildArticleTeaser(articlesList, article);
const articlePromises = [...articles].map(async (article) => {
const articletTeaserWrapper = document.createElement('div');
articletTeaserWrapper.classList.add('article-teaser-wrapper');
const articleTeaser = document.createElement('div');
articleTeaser.classList.add('article-teaser');
articleTeaser.classList.add('block');
articletTeaserWrapper.append(articleTeaser);
current = (current === leftDiv) ? rightDiv : leftDiv;
current.append(articletTeaserWrapper);
await buildArticleTeaser(articleTeaser, article);
});
block.replaceChildren(articlesList);
await Promise.all(articlePromises);

parentDiv.append(leftDiv);
parentDiv.append(rightDiv);
block.replaceChildren(parentDiv);
}
}
6 changes: 3 additions & 3 deletions cigaradvisor/blocks/author-card/author-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export default async function decorate(block) {
authorWrapperSection.innerHTML = '';
const authorPromises = [...authors].map(async (authorPage) => {
const authorInfo = await fetchData(getRelativePath(authorPage), '/cigaradvisor/author/query-index.json');
if (authorInfo) {
if (authorInfo[0]) {
return `<div class="author-content">
<div class="overlay-image">
${createOptimizedPicture(authorInfo.image).outerHTML}
${createOptimizedPicture(authorInfo[0].image).outerHTML}
<div class="overlay-content">
<p class="align-center"><a href="${authorInfo.page}">${authorInfo.name}</a></p>
<p class="align-center"><a href="${authorInfo[0].page}">${authorInfo[0].name}</a></p>
</div>
</div>
</div>`;
Expand Down

0 comments on commit 5c2a3e8

Please sign in to comment.