* Move lib/search/sync.js to script/search/sync.js * Move mdast-util-from-markdown to devDeps * Move lib/redirects/add-redirect-to-frontmatter.js to script/helpers/ * Move mkdirp to devDeps * Move linkinator to devDeps * Move rimraf to devDeps * Fix script/search/sync.js require paths * Move lib/search/build-records.js to script/search/ * Move lib/search/find-indexable-pages to script/search/ * Fix require paths for build-records * Fix require paths for find-indexable-pages * Move lib/search/algolia-get-remote-index-names.js to script/search/ * Movbe lib/search/algolia-search-index.js to script/search/ * Move lib/search/lunr-search-index.js to script/search/ * Move lib/search/lunr-get-index-names.js to script/search/ * Fix Lunr search index paths * Move lib/search/validate-records.js to script/search/ * Move is-url to devDeps * Move lib/search/algolia-client.js to script/search/ * Move lib/search/parse-page-sections-into-records.js to script/search/ * Move lib/search/rank.js to script/search/ * Fix path to cached-index-names.json file * Normalize require for fs.promises
22 lines
641 B
JavaScript
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
|
|
}
|