feat: Refactor blog components and add pagination

This commit is contained in:
Wini_Fy
2026-02-03 17:05:09 +07:00
parent bf652a64b6
commit 29cc0bf2cd
27 changed files with 2051 additions and 429 deletions

20
utils/slugify.ts Normal file
View File

@@ -0,0 +1,20 @@
/**
* Simple slugify helper (Vietnamese-friendly) to match CMS behavior:
* - lowercased
* - diacritics removed (NFD)
* - "đ" -> "d"
* - strict: keep [a-z0-9 -] only, then collapse spaces/hyphens
*/
export function toSlug(input: string): string {
return (input || "")
.trim()
.toLowerCase()
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.replace(/đ/g, "d")
.replace(/[^a-z0-9\s-]/g, "")
.replace(/\s+/g, "-")
.replace(/-+/g, "-")
.replace(/^-|-$/g, "");
}