1
0
mirror of synced 2026-01-08 21:02:10 -05:00
Files
docs/script/search/rank.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

19 lines
650 B
JavaScript

#!/usr/bin/env node
// 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()
export default 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
}