forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrank.js
More file actions
18 lines (15 loc) · 650 Bytes
/
rank.js
File metadata and controls
18 lines (15 loc) · 650 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/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
}