import { ArticleContent } from '@/lib/types/content';
import { Author, Tag } from '@/lib/types/taxonomy';
import { isValidCover } from '@/lib/utils/guards';

import styles from './Header.module.css';
import Overline from '@/components/Article/Header/Overline';
import Title from '@/components/Article/Header/Title';
import Meta from '@/components/Article/Header/Meta';
import Cover from '@/components/Article/Header/Cover';

interface HeaderProps {
  article: ArticleContent;
  breadcrumbs?: string[];
  author: Author | null;
  tags: Tag[];
}

export default function Header({
  article,
  breadcrumbs,
  author,
  tags,
}: HeaderProps) {
  const { title, meta, cover } = article;
  return (
    <header className={styles.container}>
      <Overline
        publicationDate={article.meta.publicationDate}
        breadcrumbs={breadcrumbs}
      />
      <Title title={article.title} />
      {cover && isValidCover(cover) && <Cover cover={cover} />}
      <Meta
        tags={tags}
        author={author}
        updateDate={meta.updateDate}
        publicationDate={meta.publicationDate}
      />
    </header>
  );
}
