---
import DividedList from '@/components/divided-list.astro';
import Divider from '@/components/divider.astro';
import SectionCard from '@/components/section-card.astro';
import type { SectionKey } from '@/types/data';
import type { I18n } from '@/types/i18n';
import type { PortfolioSection } from '@/types/portfolio-section';
import removeLast from '@/utils/remove-last';

import ProjectTimelineItem from './project-timeline-item.astro';

export interface Props extends PortfolioSection {
  i18n: I18n;
}

const {
  config: { title },
  projects,
  i18n,
} = Astro.props;

const section: SectionKey = 'portfolio';
---

<SectionCard section={section} title={title}>
  <DividedList>
    {removeLast(projects.flatMap((project) => [<ProjectTimelineItem project={project} i18n={i18n} />, <Divider />]))}
  </DividedList>
</SectionCard>
