chore: restore popular posts

This commit is contained in:
Cory Dransfeldt 2023-08-26 19:42:28 -07:00
parent 713c3c219e
commit 5d637ee7b7
No known key found for this signature in database
7 changed files with 27 additions and 5 deletions

View file

@ -28,10 +28,10 @@ module.exports = {
getPopularPosts: (posts, analytics) => {
return posts
.filter((post) => {
if (analytics.find((p) => p.pathname === post.url)) return true
if (analytics.find((p) => p.url.includes(post.url))) return true
})
.sort((a, b) => {
const visitors = (page) => analytics.filter((p) => p.pathname === page.url).pop().visitors
const visitors = (page) => analytics.filter((p) => p.url.includes(page.url)).pop().value
return visitors(b) - visitors(a)
})
},