mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
Replace internal slug codes with slugify function
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
---
|
---
|
||||||
|
import slugify from "src/utils/slugify";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
name: string;
|
name: string;
|
||||||
size?: "sm" | "lg";
|
size?: "sm" | "lg";
|
||||||
@@ -6,11 +8,7 @@ export interface Props {
|
|||||||
|
|
||||||
const { name, size = "sm" } = Astro.props;
|
const { name, size = "sm" } = Astro.props;
|
||||||
|
|
||||||
const slug = ((str: string) =>
|
const slug = slugify(name);
|
||||||
str
|
|
||||||
.toLowerCase()
|
|
||||||
.replace(/ /g, "-")
|
|
||||||
.replace(/[^\w-]+/g, ""))(name);
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<li class="inline-block my-1">
|
<li class="inline-block my-1">
|
||||||
|
|||||||
Reference in New Issue
Block a user