diff options
Diffstat (limited to 'src/pages/index.astro')
| -rw-r--r-- | src/pages/index.astro | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/pages/index.astro b/src/pages/index.astro index 1bc088c..e3884ef 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,23 +1,27 @@ --- -import { type CollectionEntry, getCollection } from "astro:content"; +import type { CollectionEntry } from "astro:content"; import PostPreview from "@/components/blog/PostPreview.astro"; -import Note from "@/components/note/Note.astro"; import SocialList from "@/components/SocialList.astro"; import { getAllPosts } from "@/data/post"; import PageLayout from "@/layouts/Base.astro"; import { collectionDateSort } from "@/utils/date"; -// Posts -const MAX_POSTS = 10; +// Get all posts const allPosts = await getAllPosts(); -const allPostsByDate = allPosts + +// Posts section - exclude archived and microblog +const MAX_POSTS = 10; +const regularPosts = allPosts.filter( + (post) => !post.data.tags.includes("archived") && !post.data.tags.includes("microblog"), +); +const allPostsByDate = regularPosts .sort(collectionDateSort) .slice(0, MAX_POSTS) as CollectionEntry<"post">[]; -// Micro -const MAX_MICRO = 5; -const allMicro = await getCollection("micro").catch(() => []); // Fallback to empty array if micro collection fails -const latestMicro = allMicro.sort(collectionDateSort).slice(0, MAX_MICRO); +// Microblog posts section - only posts with microblog tag +const MAX_MICROBLOG = 5; +const allMicroblogPosts = allPosts.filter((post) => post.data.tags.includes("microblog")); +const latestMicroblog = allMicroblogPosts.sort(collectionDateSort).slice(0, MAX_MICROBLOG); --- <PageLayout meta={{ title: "Home" }}> @@ -46,15 +50,15 @@ const latestMicro = allMicro.sort(collectionDateSort).slice(0, MAX_MICRO); </ul> </section> { - latestMicro.length > 0 && ( + latestMicroblog.length > 0 && ( <section class="mt-16"> <h2 class="title text-accent mb-6 text-xl"> - <a href="/tags/micro/">Micro</a> + <a href="/tags/microblog/">Microblog</a> </h2> <ul class="space-y-6" role="list"> - {latestMicro.map((note) => ( - <li> - <Note note={note} as="h3" isPreview /> + {latestMicroblog.map((post) => ( + <li class="grid gap-2 sm:grid-cols-[auto_1fr]"> + <PostPreview post={post} as="h3" /> </li> ))} </ul> |
