1
0
mirror of synced 2025-12-21 19:06:49 -05:00
Files
docs/lib/search/rank.js
Kevin Heis 2fb2e962bc Move site search to use an endpoint (#17359)
* Move site search to use an endpoint

* Update browser.js

* Update search.js

* Update lib/search/versions.js

Co-authored-by: James M. Greene <JamesMGreene@github.com>

* Fix URLs

Co-authored-by: James M. Greene <JamesMGreene@github.com>
2021-01-20 15:37:42 +00: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
}