first commit

This commit is contained in:
amirhosein.ashourloo
2026-09-02 17:03:23 +03:30
commit 1bd131e9d8
91 changed files with 11211 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
// Canonical Meshkee detail URLs are /{id}/{slug} — the slug segment is
// SEO-only, so it is built from the Farsi name rather than the DB slug.
export function faSlug(input: string | null | undefined): string {
if (!input) return "-";
return (
input
.trim()
.replace(/[\/\?%*:|"'<>.,()]/g, "")
.replace(/\s+/g, "-")
.slice(0, 80) || "-"
);
}
export function productHref(id: string, nameFa?: string | null, title?: string | null): string {
return `/products/${id}/${faSlug(nameFa || title)}`;
}
export function categoryHref(id: string, nameFa?: string | null, name?: string | null): string {
return `/products/category/${id}/${faSlug(nameFa || name)}`;
}
export function blogHref(id: string, title?: string | null): string {
return `/blog/${id}/${faSlug(title)}`;
}