From e7b93c560fd455c5432845b5a79610cd4c468d88 Mon Sep 17 00:00:00 2001 From: satnaing Date: Thu, 26 Jan 2023 22:42:15 +0630 Subject: [PATCH] refactor: modify slugger for blog content collection --- src/utils/slugify.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/slugify.ts b/src/utils/slugify.ts index 4a342ae..3a04e5f 100644 --- a/src/utils/slugify.ts +++ b/src/utils/slugify.ts @@ -1,10 +1,10 @@ +import type { CollectionEntry } from "astro:content"; import { slug as slugger } from "github-slugger"; -import type { Frontmatter } from "src/types"; export const slugifyStr = (str: string) => slugger(str); -const slugify = (frontmatter: Frontmatter) => - frontmatter.slug ? slugger(frontmatter.slug) : slugger(frontmatter.title); +const slugify = (post: CollectionEntry<"blog">) => + post.data.slug ? slugger(post.data.slug) : post.slug; export const slufigyAll = (arr: string[]) => arr.map(str => slugifyStr(str));