mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
refactor: use astro generated CollectionEntry type
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user