mirror of
https://github.com/10h30/blog-balodeplao.git
synced 2026-05-12 23:21:16 +09:00
feat: refactor taxonomy data handling for categories, destinations, and tags
This commit is contained in:
@@ -7,8 +7,8 @@ import Pagination from "@/components/ui/Pagination.astro";
|
||||
import type { Page } from "astro";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import {
|
||||
categoryMap,
|
||||
getCategoryPath,
|
||||
getTaxonomyMap,
|
||||
getTaxonomyPath,
|
||||
type TaxonomyItem,
|
||||
} from "@/utils/taxonomy";
|
||||
|
||||
@@ -27,8 +27,10 @@ export async function getStaticPaths() {
|
||||
.filter((post) => post.data.categories?.includes(slug))
|
||||
.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
|
||||
|
||||
const fullPath = getCategoryPath(slug);
|
||||
const cat = categoryMap.get(slug) ?? ({ slug, name: slug } as TaxonomyItem);
|
||||
const fullPath = getTaxonomyPath("category", slug);
|
||||
const cat =
|
||||
getTaxonomyMap("category").get(slug) ??
|
||||
({ slug, name: slug } as TaxonomyItem);
|
||||
const totalPages = Math.max(1, Math.ceil(catPosts.length / PAGE_SIZE));
|
||||
|
||||
return Array.from({ length: totalPages }, (_, i) => {
|
||||
@@ -65,7 +67,7 @@ const page = {
|
||||
currentPage,
|
||||
lastPage,
|
||||
url: { prev: prevUrl, next: nextUrl },
|
||||
} as unknown as Page<CollectionEntry<"blog">>;
|
||||
};
|
||||
|
||||
const metadata = {
|
||||
title: cat.name,
|
||||
|
||||
Reference in New Issue
Block a user