diff --git a/src/utils/getPostsByTag.ts b/src/utils/getPostsByTag.ts new file mode 100644 index 0000000..a98aa7e --- /dev/null +++ b/src/utils/getPostsByTag.ts @@ -0,0 +1,8 @@ +import type { MarkdownInstance } from "astro"; +import { slufigyAll } from "./slugify"; +import type { Frontmatter } from "./types"; + +const getPostsByTag = (posts: MarkdownInstance[], tag: string) => + posts.filter((post) => slufigyAll(post.frontmatter.tags).includes(tag)); + +export default getPostsByTag;