---
import { getTerm, getEmDashCollection, decodeSlug } from "emdash";
import { Image } from "emdash/ui";
import Base from "../../layouts/Base.astro";
const slug = decodeSlug(Astro.params.slug);
const term = slug ? await getTerm("category", slug) : null;
if (!term) {
return Astro.redirect("/404");
}
const { entries: posts } = await getEmDashCollection("posts", {
where: { category: term.slug },
orderBy: { published_at: "desc" },
});
---
{posts.length} {posts.length === 1 ? "post" : "posts"}
{ posts.length === 0 ? (No posts in this category yet.
) : ({post.data.excerpt}
}