feat: kategori sayfalarını ekle

This commit is contained in:
log101 2025-09-16 05:45:57 +03:00
parent c61d9a9355
commit abbe9f6531

View File

@ -1,7 +1,6 @@
--- ---
import type { Page } from "astro"; import type { Page } from "astro";
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
import { CATEGORIES } from "@/content/config";
import Header from "@/components/Header.astro"; import Header from "@/components/Header.astro";
import Footer from "@/components/Footer.astro"; import Footer from "@/components/Footer.astro";
@ -9,19 +8,16 @@ import Layout from "@/layouts/Layout.astro";
import Post from "@/components/Post.astro"; import Post from "@/components/Post.astro";
export async function getStaticPaths({ paginate }: { paginate: any }) { export async function getStaticPaths({ paginate }: { paginate: any }) {
const blogEntries = await getCollection("blog"); const posts = await getCollection("posts");
const allReviews = await getCollection("bookReview"); const categories = await getCollection("categories");
const allPosts = [...allReviews, ...blogEntries].filter( return categories.flatMap((category) => {
(post) => !post.data.draft const filteredPosts = posts.filter((post) =>
); post.data.categories.find((c) => c.id === category.id)
return CATEGORIES.flatMap((category) => {
const filteredPosts = allPosts.filter(
(post) => post.data.category == category
); );
return paginate(filteredPosts, { return paginate(filteredPosts, {
params: { category }, params: { category: category.data.slug },
pageSize: 3, pageSize: 3,
}); });
}); });