---
import Fonts from '@/components/fonts.astro';
import Footer from '@/pdf/components/footer.astro';
import EducationSection from '@/pdf/sections/education-section.pdf.astro';
import ExperienceSection from '@/pdf/sections/experience-section.pdf.astro';
import MainSection from '@/pdf/sections/main-section.pdf.astro';
import PortfolioSection from '@/pdf/sections/portfolio-section.pdf.astro';
import SkillsSection from '@/pdf/sections/skills-section.pdf.astro';

import cv from '@/data';

const { config, sections } = cv();

const shouldRenderSection = (section: keyof typeof sections) => sections[section] && sections[section].config.visible;
---

<!DOCTYPE html>
<html lang={config.i18n.locale.code}>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <title>PDF preview</title>
    <Fonts />
  </head>
  <body class="flex flex-col bg-white p-[10mm] print:p-0">
    {shouldRenderSection('main') && <MainSection {...sections.main} />}
    {shouldRenderSection('skills') && <SkillsSection {...sections.skills} />}
    {shouldRenderSection('experience') && <ExperienceSection {...sections.experience} />}
    {shouldRenderSection('portfolio') && <PortfolioSection {...sections.portfolio} />}
    {shouldRenderSection('education') && <EducationSection {...sections.education} />}
    {config.pdf?.footer && <Footer>{config.pdf.footer}</Footer>}
  </body>
</html>
