diff --git a/src/utils/blogs.ts b/src/utils/blogs.ts index 50d16646..38ddae5d 100644 --- a/src/utils/blogs.ts +++ b/src/utils/blogs.ts @@ -170,9 +170,11 @@ export async function getAllBlogs(sortBy = 'all', pref } } default: { - if (blog1?.category?.startsWith(sortBy) && !blog2?.category?.startsWith(sortBy)) { + const b1Categories = blog1?.category?.split(',') ?? [] + const b2Categories = blog2?.category?.split(',') ?? [] + if (b1Categories.includes(sortBy) && !b2Categories?.includes(sortBy)) { return -1 - } else if (!blog1?.category?.startsWith(sortBy) && blog2?.category?.startsWith(sortBy)) { + } else if (!b1Categories.includes(sortBy) && b2Categories.includes(sortBy)) { return 1 } else if (blog1?.date && blog2?.date) { return blog1?.date > blog2?.date ? -1 : 1