Provide assets on all search hits
This commit is contained in:
parent
8ed2296b2f
commit
0bdbca30d4
|
@ -14,16 +14,17 @@ function enhanceHit(hit) {
|
|||
|
||||
resolve(hit)
|
||||
} else {
|
||||
// We don't have any global paths for this package yet. Try
|
||||
// using the "bare" URL.
|
||||
hit.assets = [
|
||||
`https://unpkg.com/${hit.name}@${hit.version}`
|
||||
]
|
||||
|
||||
resolve(hit)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function byRelevanceDescending(a, b) {
|
||||
// Hits that have assets are more relevant.
|
||||
return a.assets ? (b.assets ? 0 : -1) : (b.assets ? 1 : 0)
|
||||
}
|
||||
|
||||
// add concatenated name for more relevance for people spelling without spaces
|
||||
// think: createreactnative instead of create-react-native-app
|
||||
function concat(string) {
|
||||
|
@ -65,8 +66,6 @@ function search(query, page) {
|
|||
Promise.all(
|
||||
value.hits.map(enhanceHit)
|
||||
).then(function (hits) {
|
||||
hits.sort(byRelevanceDescending)
|
||||
|
||||
const totalHits = value.nbHits
|
||||
const totalPages = value.nbPages
|
||||
|
||||
|
|
Loading…
Reference in New Issue