mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
@@ -9,6 +9,7 @@ import getUniqueTags from "@utils/getUniqueTags";
|
|||||||
import getPostsByTag from "@utils/getPostsByTag";
|
import getPostsByTag from "@utils/getPostsByTag";
|
||||||
import slugify from "@utils/slugify";
|
import slugify from "@utils/slugify";
|
||||||
import { SITE } from "@config";
|
import { SITE } from "@config";
|
||||||
|
import getSortedPosts from "@utils/getSortedPosts";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
post: CollectionEntry<"blog">;
|
post: CollectionEntry<"blog">;
|
||||||
@@ -33,6 +34,8 @@ const { tag } = Astro.props;
|
|||||||
const posts = await getCollection("blog", ({ data }) => !data.draft);
|
const posts = await getCollection("blog", ({ data }) => !data.draft);
|
||||||
|
|
||||||
const tagPosts = getPostsByTag(posts, tag);
|
const tagPosts = getPostsByTag(posts, tag);
|
||||||
|
|
||||||
|
const sortTagsPost = getSortedPosts(tagPosts);
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={`Tag:${tag} | ${SITE.title}`}>
|
<Layout title={`Tag:${tag} | ${SITE.title}`}>
|
||||||
@@ -43,7 +46,7 @@ const tagPosts = getPostsByTag(posts, tag);
|
|||||||
>
|
>
|
||||||
<ul>
|
<ul>
|
||||||
{
|
{
|
||||||
tagPosts.map(({ data }) => (
|
sortTagsPost.map(({ data }) => (
|
||||||
<Card href={`/posts/${slugify(data)}`} frontmatter={data} />
|
<Card href={`/posts/${slugify(data)}`} frontmatter={data} />
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user