refactor: use astro generated CollectionEntry type

This commit is contained in:
tanishqmanuja
2023-09-20 14:49:56 +05:30
committed by Sat Naing
parent 0af32518b3
commit 1cc51c00a7
4 changed files with 6 additions and 8 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
import { slug as slugger } from "github-slugger";
import type { BlogFrontmatter } from "@content/_schemas";
import type { CollectionEntry } from "astro:content";
export const slugifyStr = (str: string) => slugger(str);
const slugify = (post: BlogFrontmatter) =>
const slugify = (post: CollectionEntry<"blog">["data"]) =>
post.postSlug ? slugger(post.postSlug) : slugger(post.title);
export const slugifyAll = (arr: string[]) => arr.map(str => slugifyStr(str));