mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +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 { slug as slugger } from "github-slugger";
|
||||||
import type { Frontmatter } from "src/types";
|
|
||||||
|
|
||||||
export const slugifyStr = (str: string) => slugger(str);
|
export const slugifyStr = (str: string) => slugger(str);
|
||||||
|
|
||||||
const slugify = (frontmatter: Frontmatter) =>
|
const slugify = (post: CollectionEntry<"blog">) =>
|
||||||
frontmatter.slug ? slugger(frontmatter.slug) : slugger(frontmatter.title);
|
post.data.slug ? slugger(post.data.slug) : post.slug;
|
||||||
|
|
||||||
export const slufigyAll = (arr: string[]) => arr.map(str => slugifyStr(str));
|
export const slufigyAll = (arr: string[]) => arr.map(str => slugifyStr(str));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user