mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
refactor: modify slugger for blog content collection
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user