feat: kategori sayfalarını ekle
This commit is contained in:
parent
c61d9a9355
commit
abbe9f6531
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
import type { Page } from "astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import { CATEGORIES } from "@/content/config";
|
||||
|
||||
import Header from "@/components/Header.astro";
|
||||
import Footer from "@/components/Footer.astro";
|
||||
|
@ -9,19 +8,16 @@ import Layout from "@/layouts/Layout.astro";
|
|||
import Post from "@/components/Post.astro";
|
||||
|
||||
export async function getStaticPaths({ paginate }: { paginate: any }) {
|
||||
const blogEntries = await getCollection("blog");
|
||||
const allReviews = await getCollection("bookReview");
|
||||
const posts = await getCollection("posts");
|
||||
const categories = await getCollection("categories");
|
||||
|
||||
const allPosts = [...allReviews, ...blogEntries].filter(
|
||||
(post) => !post.data.draft
|
||||
);
|
||||
|
||||
return CATEGORIES.flatMap((category) => {
|
||||
const filteredPosts = allPosts.filter(
|
||||
(post) => post.data.category == category
|
||||
return categories.flatMap((category) => {
|
||||
const filteredPosts = posts.filter((post) =>
|
||||
post.data.categories.find((c) => c.id === category.id)
|
||||
);
|
||||
|
||||
return paginate(filteredPosts, {
|
||||
params: { category },
|
||||
params: { category: category.data.slug },
|
||||
pageSize: 3,
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user