mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
refactor: move filtering draft to getCollection func
This commit is contained in:
@@ -8,12 +8,10 @@ import Footer from "@components/Footer.astro";
|
|||||||
import Search from "@components/Search";
|
import Search from "@components/Search";
|
||||||
|
|
||||||
// Retrieve all articles
|
// Retrieve all articles
|
||||||
const posts = await getCollection("blog");
|
const posts = await getCollection("blog", ({ data }) => !data.draft);
|
||||||
|
|
||||||
// List of items to search in
|
// List of items to search in
|
||||||
const searchList = posts
|
const searchList = posts.map(({ data }) => ({
|
||||||
.filter(({ data }) => !data.draft)
|
|
||||||
.map(({ data }) => ({
|
|
||||||
title: data.title,
|
title: data.title,
|
||||||
description: data.description,
|
description: data.description,
|
||||||
data,
|
data,
|
||||||
|
|||||||
Reference in New Issue
Block a user