Add filter for draft posts

This commit is contained in:
Sat Naing
2022-09-22 23:37:09 +06:30
parent b8b7aaef7d
commit 00689f1cba
+8 -6
View File
@@ -13,12 +13,14 @@ localStorage.setItem("myCat", "Tom");
const posts = await Astro.glob<Frontmatter>("../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,
}));
---
<Layout title={`Search | ${SITE.title}`}>