update: add blog category to the blog in landing
This commit is contained in:
@@ -189,6 +189,8 @@ export class BlogsRepository extends Repository<Blog> {
|
|||||||
|
|
||||||
async getPinnedBlogs(limit: number = 4) {
|
async getPinnedBlogs(limit: number = 4) {
|
||||||
return this.createQueryBuilder("blog")
|
return this.createQueryBuilder("blog")
|
||||||
|
.leftJoinAndSelect("blog.category", "category")
|
||||||
|
.addSelect(["category.id", "category.title", "category.iconUrl"])
|
||||||
.where("blog.deletedAt IS NULL")
|
.where("blog.deletedAt IS NULL")
|
||||||
.andWhere("blog.isActive = :isActive", { isActive: true })
|
.andWhere("blog.isActive = :isActive", { isActive: true })
|
||||||
.andWhere("blog.isPinned = :isPinned", { isPinned: true })
|
.andWhere("blog.isPinned = :isPinned", { isPinned: true })
|
||||||
@@ -202,6 +204,9 @@ export class BlogsRepository extends Repository<Blog> {
|
|||||||
"blog.slug",
|
"blog.slug",
|
||||||
"blog.createdAt",
|
"blog.createdAt",
|
||||||
"blog.viewCount",
|
"blog.viewCount",
|
||||||
|
"category.id",
|
||||||
|
"category.title",
|
||||||
|
"category.iconUrl",
|
||||||
])
|
])
|
||||||
.orderBy("blog.createdAt", "DESC")
|
.orderBy("blog.createdAt", "DESC")
|
||||||
.take(limit)
|
.take(limit)
|
||||||
|
|||||||
Reference in New Issue
Block a user