Skip to content

Commit

Permalink
fix: ignore nulls in article array (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
120EE0692 authored Oct 15, 2022
1 parent f798de1 commit e910723
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/src/pages/portfolio/[...userId].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,16 @@ export async function getStaticProps({
},
});

const noOfArticle = articleList.length;
const _articleList = articleList.filter((article) => article);
const noOfArticle = _articleList.length;

let { store, storePath } = picture;
let profileImageLink = getStores[store] + storePath;

let year = ' ';

if (noOfArticle) {
year = articleList[noOfArticle - 1].createdAt.substring(0, 4);
year = _articleList[noOfArticle - 1].createdAt.substring(0, 4);
year += '-' + (Number(year.substring(2)) + 1).toString();
}

Expand All @@ -155,7 +156,7 @@ export async function getStaticProps({
lastName,
email,
profileImageLink,
articleList,
articleList: _articleList,
noOfArticle,
year,
},
Expand Down

0 comments on commit e910723

Please sign in to comment.