From 8504d6595fa657c73368b20818acd0dd8406bc91 Mon Sep 17 00:00:00 2001 From: neil molina Date: Wed, 22 Mar 2023 08:55:59 +0800 Subject: [PATCH] #294 index maintainer data --- src/layouts/partials/package-grid.html | 8 +++++--- src/layouts/partials/package-thumbnail.html | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/layouts/partials/package-grid.html b/src/layouts/partials/package-grid.html index 85c1396..93a7e9d 100644 --- a/src/layouts/partials/package-grid.html +++ b/src/layouts/partials/package-grid.html @@ -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; diff --git a/src/layouts/partials/package-thumbnail.html b/src/layouts/partials/package-thumbnail.html index 1ba5fe3..7fc5dd6 100644 --- a/src/layouts/partials/package-thumbnail.html +++ b/src/layouts/partials/package-thumbnail.html @@ -1,4 +1,4 @@ -
+