Skip to content

Commit

Permalink
Added readtime for post and recommended post
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-ashish-k committed Feb 8, 2024
1 parent 922a7f5 commit 8f3d17a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions admin/src/api/post/controllers/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,16 @@ module.exports = createCoreController("api::post.post", ({ strapi }) => ({
},
},
});
recommandedPosts.forEach(post => {
post.readingTime=getReadingTime(post.content);
});

entity.recommandedPosts = recommandedPosts
.filter((post) => {
return entity.tags
.map((t) => t.name)
.some((r) => post.tags.map((t) => t.name).includes(r));
})
.map((post) => {
post.readingTime = getReadingTime(post.content);
return post;
});

return this.transformResponse(entity);
},
Expand Down

0 comments on commit 8f3d17a

Please sign in to comment.