Files
MyBlog-Next/src/utils/slugify.ts
T
2023-01-28 00:47:21 +06:30

12 lines
378 B
TypeScript

import { slug as slugger } from "github-slugger";
import type { BlogFrontmatter } from "@content/_schemas";
export const slugifyStr = (str: string) => slugger(str);
const slugify = (post: BlogFrontmatter) =>
post.postSlug ? slugger(post.postSlug) : slugger(post.title);
export const slufigyAll = (arr: string[]) => arr.map(str => slugifyStr(str));
export default slugify;