---
import type { BlogEntry } from "@/types";
import { sortByDate } from "@lib/sortFunctions";
import EntryLayout from "@components/blog/EntryLayout.astro";
import { getEntries } from "@lib/contentParser";
import similerItems from "@lib/similarItems";

export async function getStaticPaths() {
  const entries = (await getEntries("blog", sortByDate)) as BlogEntry[];
  const paths = entries.map((entry) => ({
    params: {
      entry: entry.id,
    },
    props: { entry, entries },
  }));
  return paths;
}

const { entry, entries } = Astro.props;
const relatedEntries = similerItems(entry, entries, entry.id);
---

<EntryLayout entry={entry} relatedEntries={relatedEntries} />
