#294 index maintainer data

This commit is contained in:
neil molina 2023-03-22 08:55:59 +08:00
parent d3e1a4066d
commit 8504d6595f
2 changed files with 6 additions and 4 deletions

View file

@ -121,11 +121,13 @@
if (searchInput.value) {
const term = searchInput.value;
const packages = getPackageThumbs();
for(let pkg of packages) {
pkg.match_score = getMatchScore(term, pkg.dataset);
}
const sortedPackages = packages.sort((a, b) => {
const aScore = getMatchScore(term, a.dataset);
const bScore = getMatchScore(term, b.dataset);
return bScore - aScore;
return b.match_score - (a ? a.match_score : 0);
});
const grid = document.getElementById('packageGrid');
grid.textContent = '';
let searchCount = 0;

View file

@ -1,4 +1,4 @@
<div class="card card-thumbnail" style="width: 100%" data-name="{{- .name -}}" data-popularity="{{- .dl_count -}}" data-last_modified="{{- .last_modified -}}" data-description="{{- .desc -}}">
<div class="card card-thumbnail" style="width: 100%" data-name="{{- .name -}}" data-popularity="{{- .dl_count -}}" data-last_modified="{{- .last_modified -}}" data-description="{{- .desc -}}" data-maintainer="{{- .maintainer -}}">
<a href="/+{{- lower .full_name -}}/">
<div class="p-3">
<figure class="card-img-top" >