Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ljc1991 committed Oct 28, 2023
1 parent 0d7e346 commit 5a9c0ac
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions homepage/src/lib/componentMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ export const componentTypes = {
Cards: 'Cards',
};

const extendProjectCardTagsContent = (projectCards, jobCards) => {
return projectCards.map((projectCard) => {
const tags = projectCard.data.tags;
let avatarList = [];
if (tags) {
avatarList = tags.map((tag) => {
const jobCard = jobCards.find((jobCard) => jobCard.data.title === tag);
if (jobCard) {
return jobCard.data;
}
return null;
}).filter(x => x);
}
return {
...projectCard,
avatarList,
};
});
}
// const extendProjectCardTagsContent = (projectCards, jobCards) => {
// return projectCards.map((projectCard) => {
// const tags = projectCard.data.tags;
// let avatarList = [];
// if (tags) {
// avatarList = tags.map((tag) => {
// const jobCard = jobCards.find((jobCard) => jobCard.data.title === tag);
// if (jobCard) {
// return jobCard.data;
// }
// return null;
// }).filter(x => x);
// }
// return {
// ...projectCard,
// avatarList,
// };
// });
// }

export const componentMapper = (layout, cards = []) => {
let type = '';
Expand Down Expand Up @@ -123,24 +123,26 @@ export const componentMapper = (layout, cards = []) => {
layout.card_tags.every((tag) => card.data.tags?.includes(tag)),
);
}
if (layout.card_type === 'card_project') {
type = componentTypes.Cards;
props = {
id: titleToAnchorId(layout.title),
title: layout.title,
cards: extendProjectCardTagsContent(filteredCards, cards.filter((card) => card.data.type === 'job_card')),
};
break;
}
else {
type = componentTypes.Cards;
props = {
id: titleToAnchorId(layout.title),
title: layout.title,
cards: filteredCards,
};
break;
}
// if (layout.card_type === 'card_project') {
// type = componentTypes.Cards;
// props = {
// id: titleToAnchorId(layout.title),
// title: layout.title,
// cards: extendProjectCardTagsContent(
// filteredCards,
// cards.filter((card) => card.data.type === 'job_card'),
// ),
// };
// break;
// } else {
type = componentTypes.Cards;
props = {
id: titleToAnchorId(layout.title),
title: layout.title,
cards: filteredCards,
};
break;
// }
}
}

Expand Down

0 comments on commit 5a9c0ac

Please sign in to comment.