mirror of
https://github.com/10h30/blog-balodeplao.git
synced 2026-05-12 23:21:16 +09:00
feat: implement taxonomy data for categories, destinations, and tags with updated routing (#2)
This commit is contained in:
@@ -1,21 +1,37 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import Headline from "@/components/ui/Headline.astro";
|
||||
import Pagination from "@/components/ui/Pagination.astro";
|
||||
import PostItem from "@/components/blog/PostItem.astro";
|
||||
import type { GetStaticPathsOptions } from "astro";
|
||||
import { buildPaginatedPaths } from "@/utils/paginate";
|
||||
|
||||
export async function getStaticPaths({ paginate }: GetStaticPathsOptions) {
|
||||
interface Props {
|
||||
page: {
|
||||
data: CollectionEntry<"blog">[];
|
||||
total: number;
|
||||
currentPage: number;
|
||||
lastPage: number;
|
||||
url: { prev?: string; next?: string };
|
||||
};
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection("blog");
|
||||
const sortedPosts = blogEntries
|
||||
.filter((post) => post.data && post.data.pubDate)
|
||||
.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
|
||||
|
||||
return paginate(sortedPosts, { pageSize: 6 });
|
||||
return buildPaginatedPaths(sortedPosts, "/blog").map(
|
||||
({ pageParam, page }) => ({
|
||||
params: { page: pageParam },
|
||||
props: { page },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const { page } = Astro.props;
|
||||
const { page } = Astro.props as Props;
|
||||
const blog = page.data;
|
||||
|
||||
const metadata = {
|
||||
|
||||
Reference in New Issue
Block a user