From 00689f1cbab288b6ef4eda4a58a8f11823cd04f2 Mon Sep 17 00:00:00 2001 From: Sat Naing Date: Thu, 22 Sep 2022 23:37:09 +0630 Subject: [PATCH] Add filter for draft posts --- src/pages/search.astro | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pages/search.astro b/src/pages/search.astro index 9d7c85a..21827c9 100644 --- a/src/pages/search.astro +++ b/src/pages/search.astro @@ -13,12 +13,14 @@ localStorage.setItem("myCat", "Tom"); const posts = await Astro.glob("../contents/*.md"); // List of items to search in -const searchList = posts.map(({ frontmatter }) => ({ - title: frontmatter.title, - description: frontmatter.description, - frontmatter, - slug: frontmatter.slug, -})); +const searchList = posts + .filter(({ frontmatter }) => !frontmatter.draft) + .map(({ frontmatter }) => ({ + title: frontmatter.title, + description: frontmatter.description, + frontmatter, + slug: frontmatter.slug, + })); ---