Use Meshkee {id}/{fa-slug} detail URLs for products and blogs.

Resolve pages via by-id APIs, slugify Farsi titles for public paths, and redirect legacy slug-only URLs to the canonical form.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-22 23:52:45 +03:30
co-authored by Cursor
parent 24b5649abd
commit 0cb9aa57e2
14 changed files with 426 additions and 307 deletions
+17 -3
View File
@@ -1,4 +1,5 @@
import { meshkeeGet, tenantPath } from "@/lib/meshkee";
import { detailPath, slugifyForUrl } from "@/lib/seo-slug";
export type BlogPost = {
id: string;
@@ -32,7 +33,16 @@ export async function fetchBlogs(params: { page?: number; pageSize?: number } =
});
}
export async function fetchBlog(slug: string) {
export async function fetchBlogById(id: string) {
const data = await meshkeeGet<{ blog?: BlogPost }>(
tenantPath(`/blogs/by-id/${encodeURIComponent(id)}`),
{},
);
return data.blog ?? null;
}
/** @deprecated Prefer fetchBlogById for public detail pages. */
export async function fetchBlogBySlug(slug: string) {
const data = await meshkeeGet<{ blog?: BlogPost }>(tenantPath(`/blogs/${encodeURIComponent(slug)}`), {});
return data.blog ?? null;
}
@@ -41,6 +51,10 @@ export function blogImage(post: BlogPost) {
return post.titleImageUrl || "/placeholders/blog.svg";
}
export function blogHref(post: BlogPost) {
return `/blog/${encodeURIComponent(post.slug)}`;
export function blogHref(post: Pick<BlogPost, "id" | "title">) {
return detailPath("/blog", post.id, post.title);
}
export function blogTitleSlug(title: string) {
return slugifyForUrl(title);
}