1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/lib/algolia/rank.js
Vanessa Yuen 3df90fc9b8 Hello git history spelunker!
Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2020-09-27 14:10:11 +02:00

22 lines
641 B
JavaScript

// This module accepts an Algolia search record object as input and
// returns a ranking score which influences how results are sorted.
// higher in this list == higher search ranking
// anything NOT matched by this list gets the highest ranking
// a lower ranking means the record will have a higher priority
const rankings = [
'/rest',
'/graphql',
'/site-policy'
].reverse()
module.exports = function rank (record) {
for (const index in rankings) {
const pattern = rankings[index]
if (record.url.includes(pattern)) return Number(index)
}
// Set the default ranking to the highest possible
return rankings.length
}