diff --git a/src/utils/getSortedPosts.ts b/src/utils/getSortedPosts.ts index 292547b..d38f6a7 100644 --- a/src/utils/getSortedPosts.ts +++ b/src/utils/getSortedPosts.ts @@ -2,10 +2,12 @@ import type { MarkdownInstance } from "astro"; import type { Frontmatter } from "../types"; const getSortedPosts = (posts: MarkdownInstance[]) => - posts.sort( - (a, b) => - Math.floor(new Date(b.frontmatter.datetime).getTime() / 1000) - - Math.floor(new Date(a.frontmatter.datetime).getTime() / 1000) - ); + posts + .filter(({ frontmatter }) => !frontmatter.draft) + .sort( + (a, b) => + Math.floor(new Date(b.frontmatter.datetime).getTime() / 1000) - + Math.floor(new Date(a.frontmatter.datetime).getTime() / 1000) + ); export default getSortedPosts; diff --git a/src/utils/getUniqueTags.ts b/src/utils/getUniqueTags.ts index f4f0641..4e62cfb 100644 --- a/src/utils/getUniqueTags.ts +++ b/src/utils/getUniqueTags.ts @@ -4,7 +4,8 @@ import type { Frontmatter } from "../types"; const getUniqueTags = (posts: MarkdownInstance[]) => { let tags: string[] = []; - posts.forEach((post) => { + const filteredPosts = posts.filter(({ frontmatter }) => !frontmatter.draft); + filteredPosts.forEach((post) => { tags = [...tags, ...post.frontmatter.tags] .map((tag) => slugify(tag)) .filter(