refactor: update imports and frontmatter types

This commit is contained in:
satnaing
2023-01-28 00:47:21 +06:30
parent d67e64e02d
commit c19f3a0e5a
4 changed files with 12 additions and 14 deletions
+3 -3
View File
@@ -1,10 +1,10 @@
import type { CollectionEntry } from "astro:content";
import { slug as slugger } from "github-slugger";
import type { BlogFrontmatter } from "@content/_schemas";
export const slugifyStr = (str: string) => slugger(str);
const slugify = (post: CollectionEntry<"blog">) =>
post.data.slug ? slugger(post.data.slug) : post.slug;
const slugify = (post: BlogFrontmatter) =>
post.postSlug ? slugger(post.postSlug) : slugger(post.title);
export const slufigyAll = (arr: string[]) => arr.map(str => slugifyStr(str));