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