chore: revert back link code

This commit is contained in:
Cory Dransfeldt 2023-06-05 13:27:05 -07:00
parent 03f1b1a1a0
commit 34092dfe91
No known key found for this signature in database
3 changed files with 2 additions and 22 deletions

View file

@ -57,17 +57,4 @@ module.exports = {
return data
},
pageLinkMeta: (postUrl, collection, pageSize = 10) => {
const index = collection.findIndex((p) => p.data.page.url === postUrl)
if (index === -1) throw new Error(`${postUrl} not found in collection`)
return {
number: Math.ceil(collection.length / pageSize) - Math.ceil(index / pageSize),
slug: collection[index].fileSlug,
}
},
blogListingLink: (postUrl, collection, pageSize = 10) => {
const pageLinkMeta = module.exports.pageLinkMeta(postUrl, collection, pageSize)
if (pageLinkMeta.number === 0) return { uri: `/#${pageLinkMeta.slug}`, number: '1' }
return { uri: `/${pageLinkMeta.number}#${pageLinkMeta.slug}`, number: pageLinkMeta.number + 1 }
},
}