---
import ProjectList from '../../components/ProjectList.astro';
import Page from '../../layouts/Page.astro';
import {
  absoluteUrl,
  buildBreadcrumbJsonLd,
  buildBreadcrumbTrail,
  getProjects,
  site,
} from '../../lib/site';

const description =
  'A compact index of systems, tools, simulations, graphics experiments, games, and older work.';

const projects = await getProjects();
const selected = projects.filter((project) => project.data.project?.selected);
const older = projects.filter((project) => !project.data.project?.selected);

const collectionJsonLd = {
  '@context': 'https://schema.org',
  '@type': 'CollectionPage',
  name: `${site.name}: Projects`,
  url: absoluteUrl('/projects/'),
  description,
};

const breadcrumbJsonLd = buildBreadcrumbJsonLd(buildBreadcrumbTrail({ projects: true }));

const jsonLd = [collectionJsonLd, breadcrumbJsonLd];
---

<Page title="Projects" description={description} jsonLd={jsonLd}>
  <section class="project-section">
    <h2 id="selected-projects">Selected Projects</h2>
    <ProjectList projects={selected} eagerThumbnailCount={6} />
  </section>

  <section class="project-section">
    <h2 id="older-projects">Older and Smaller Projects</h2>
    <ProjectList projects={older} />
  </section>
</Page>
