mirror of
https://github.com/KazooTTT/kazoottt-blog-v2.git
synced 2025-06-24 11:11:29 +08:00
feat: 新增置顶文章
This commit is contained in:
@ -3,7 +3,7 @@ import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import SocialList from "@/components/SocialList.astro";
|
||||
import PostPreview from "@/components/blog/PostPreview.astro";
|
||||
import Note from "@/components/note/Note.astro";
|
||||
import { getAllPosts } from "@/data/post";
|
||||
import { getAllFixedToTopPosts, getAllPosts } from "@/data/post";
|
||||
import PageLayout from "@/layouts/Base.astro";
|
||||
import { collectionDateSort } from "@/utils/date";
|
||||
|
||||
@ -14,6 +14,12 @@ const allPostsByDate = allPosts
|
||||
.sort(collectionDateSort)
|
||||
.slice(0, MAX_POSTS) as CollectionEntry<"post">[];
|
||||
|
||||
// Fixed to top Posts
|
||||
const allFixedToTopPosts = await getAllFixedToTopPosts();
|
||||
const allFixedToTopPostsByDate = allFixedToTopPosts
|
||||
.sort(collectionDateSort)
|
||||
.slice(0, MAX_POSTS) as CollectionEntry<"post">[];
|
||||
|
||||
// Notes
|
||||
const MAX_NOTES = 6;
|
||||
const allNotes = await getCollection("note");
|
||||
@ -26,6 +32,20 @@ const latestNotes = allNotes.sort(collectionDateSort).slice(0, MAX_NOTES);
|
||||
<p class="mb-4">TODO ...</p>
|
||||
<SocialList />
|
||||
</section>
|
||||
|
||||
<section class="mt-16">
|
||||
<h2 class="title text-accent mb-6 text-xl"><a href="/posts/">置顶文章</a></h2>
|
||||
<ul class="space-y-4" role="list">
|
||||
{
|
||||
allFixedToTopPostsByDate.map((p) => (
|
||||
<li class="grid gap-2 sm:grid-cols-[auto_1fr]">
|
||||
<PostPreview post={p} />
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="mt-16">
|
||||
<h2 class="title text-accent mb-6 text-xl"><a href="/posts/">Posts</a></h2>
|
||||
<ul class="space-y-4" role="list">
|
||||
|
Reference in New Issue
Block a user