import type { LifePost, LifePostImage } from "./types";

export function getLifePostImages(post: LifePost): LifePostImage[] {
  return post.content
    .filter((block) => block.type === "image")
    .map(({ src, alt, caption, display, align, width, height }) => ({
      src,
      alt,
      caption,
      display,
      align,
      width,
      height,
    }));
}

export function getLifePostCoverImage(post: LifePost): LifePostImage | undefined {
  return getLifePostImages(post)[0];
}

export function countLifePostParagraphs(post: LifePost): number {
  return post.content.filter((block) => block.type === "paragraph").length;
}
