mirror of
https://github.com/10h30/astroplate.git
synced 2026-06-05 15:08:00 +09:00
fixed post sorting on taxonomy pages
This commit is contained in:
@@ -3,6 +3,7 @@ import BlogCard from "@/components/BlogCard.astro";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
|
||||
@@ -24,6 +25,7 @@ const { category } = Astro.params;
|
||||
const BLOG_FOLDER = "blog";
|
||||
const posts = await getSinglePage(BLOG_FOLDER);
|
||||
const filterByCategories = taxonomyFilter(posts, "categories", category!);
|
||||
const sortedPosts = sortByDate(filterByCategories);
|
||||
---
|
||||
|
||||
<Base title={category}>
|
||||
@@ -32,7 +34,7 @@ const filterByCategories = taxonomyFilter(posts, "categories", category!);
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{
|
||||
filterByCategories.map((post) => (
|
||||
sortedPosts.map((post) => (
|
||||
<div class="mb-14 md:col-6 lg:col-4">
|
||||
<BlogCard data={post} />
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import BlogCard from "@/components/BlogCard.astro";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
|
||||
@@ -23,6 +24,7 @@ const { tag } = Astro.params;
|
||||
const BLOG_FOLDER = "blog";
|
||||
const posts = await getSinglePage(BLOG_FOLDER);
|
||||
const filterByTags = taxonomyFilter(posts, "tags", tag!);
|
||||
const sortedPosts = sortByDate(filterByTags);
|
||||
---
|
||||
|
||||
<Base title={tag}>
|
||||
@@ -31,7 +33,7 @@ const filterByTags = taxonomyFilter(posts, "tags", tag!);
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{
|
||||
filterByTags.map((post) => (
|
||||
sortedPosts.map((post) => (
|
||||
<div class="mb-14 md:col-6 lg:col-4">
|
||||
<BlogCard data={post} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user