Add filter for draft posts

This commit is contained in:
Sat Naing
2022-09-22 23:37:09 +06:30
parent b8b7aaef7d
commit 00689f1cba
+4 -2
View File
@@ -13,12 +13,14 @@ localStorage.setItem("myCat", "Tom");
const posts = await Astro.glob<Frontmatter>("../contents/*.md"); const posts = await Astro.glob<Frontmatter>("../contents/*.md");
// List of items to search in // List of items to search in
const searchList = posts.map(({ frontmatter }) => ({ const searchList = posts
.filter(({ frontmatter }) => !frontmatter.draft)
.map(({ frontmatter }) => ({
title: frontmatter.title, title: frontmatter.title,
description: frontmatter.description, description: frontmatter.description,
frontmatter, frontmatter,
slug: frontmatter.slug, slug: frontmatter.slug,
})); }));
--- ---
<Layout title={`Search | ${SITE.title}`}> <Layout title={`Search | ${SITE.title}`}>