---
import type { BlogEntry } from "@/types";
import { getEntries } from "@lib/contentParser";
import { getTaxa } from "@lib/taxonomyParser";
import taxonomyFilter from "@lib/taxonomyFilter";
import TaxonLayout from "@components/blog/TaxonLayout.astro";

export async function getStaticPaths() {
  const taxa = await getTaxa("blog", "categories");
  const paths = taxa.map((taxon) => ({
    params: {
      category: taxon,
    },
    props: { taxon },
  }));
  return paths;
}

const { taxon } = Astro.props;
const entries = await getEntries("blog") as BlogEntry[];
const filteredEntries: BlogEntry[] = taxonomyFilter(entries, "categories", taxon!);
---

<TaxonLayout taxon={taxon} entries={filteredEntries} />
