Use /{id}/{fa-slug} detail URLs in sitemaps and add public by-id lookups.
Default sitemap templates now emit SEO-friendly Farsi path segments with stable CMS ids; storefronts resolve content via new by-id public endpoints. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
1b16e79d3f
commit
7cef24336a
@@ -99,6 +99,11 @@ export class PublicBlogsController {
|
||||
return this.service.listPublic(host, query);
|
||||
}
|
||||
|
||||
@Get('by-id/:blogId')
|
||||
getById(@Param('host') host: string, @Param('blogId') blogId: string) {
|
||||
return this.service.getPublicById(host, blogId);
|
||||
}
|
||||
|
||||
@Get(':blogId/comments')
|
||||
listComments(@Param('host') host: string, @Param('blogId') blogId: string) {
|
||||
return this.service.listCommentsPublic(host, blogId);
|
||||
|
||||
@@ -381,6 +381,37 @@ export class BlogsService {
|
||||
};
|
||||
}
|
||||
|
||||
async getPublicById(host: string, blogIdRaw: string) {
|
||||
const business = await this.tenant.resolveBusinessByDomain(host);
|
||||
const businessId = business.id;
|
||||
let blogId: bigint;
|
||||
try {
|
||||
blogId = BigInt(blogIdRaw);
|
||||
} catch {
|
||||
throw new NotFoundException('Blog post not found');
|
||||
}
|
||||
|
||||
const blog = await this.prisma.blogs.findFirst({
|
||||
where: {
|
||||
business_id: businessId,
|
||||
id: blogId,
|
||||
status: ContentStatus.published,
|
||||
},
|
||||
include: blogInclude,
|
||||
});
|
||||
|
||||
if (!blog) {
|
||||
throw new NotFoundException('Blog post not found');
|
||||
}
|
||||
|
||||
return {
|
||||
blog: await this.serializeBlog(blog, {
|
||||
includeComments: true,
|
||||
approvedCommentsOnly: true,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
async listCommentsPublic(host: string, blogIdRaw: string) {
|
||||
const business = await this.tenant.resolveBusinessByDomain(host);
|
||||
const businessId = business.id;
|
||||
|
||||
Reference in New Issue
Block a user