Conditional Return With Flat Map

const posts = idList.flatMap((slug: string) => {
  const post = getPostBySlug(slug, fields);
  return post ? [post] : [];
});