diff options
-rw-r--r-- | src/static/js/client.js | 45 | ||||
-rw-r--r-- | src/util/search-spec.js | 4 |
2 files changed, 29 insertions, 20 deletions
diff --git a/src/static/js/client.js b/src/static/js/client.js index d613bc6a..560a0d36 100644 --- a/src/static/js/client.js +++ b/src/static/js/client.js @@ -3714,19 +3714,40 @@ function showSidebarSearchResults(results) { cssProp(info.resultsContainer, 'display', 'block'); for (const result of flatResults) { - if (result.index !== 'tracks') continue; - info.results.appendChild(generateSidebarSearchTrackResult(result)); + if (result.index !== 'generic') continue; + + const el = generateSidebarSearchResult(result); + if (!el) continue; + + info.results.appendChild(el); } } function generateSidebarSearchResult(result) { + const preparedSlots = { + color: + result.data.color ?? null, + + name: + result.data.name ?? result.data.primaryName ?? null, + + imageSource: + getSearchResultImageSource(result), + }; + switch (result.referenceType) { - case 'track': - return generateSidebarSearchTrackResult(result); + case 'track': { + preparedSlots.href = + openTrack(result.directory); + + break; + } default: return null; } + + return generateSidebarSearchResultTemplate(preparedSlots); } function getSearchResultImageSource(result) { @@ -3757,22 +3778,6 @@ function getSearchResultImageSource(result) { } } -function generateSidebarSearchTrackResult(result) { - return generateSidebarSearchResultTemplate({ - href: - openTrack(result.directory), - - color: - result.data.color, - - name: - result.data.name, - - imageSource: - getSearchResultImageSource(result), - }); -} - function generateSidebarSearchResultTemplate(slots) { const link = document.createElement('a'); link.classList.add('wiki-search-result'); diff --git a/src/util/search-spec.js b/src/util/search-spec.js index e8bc7571..d8ae936e 100644 --- a/src/util/search-spec.js +++ b/src/util/search-spec.js @@ -42,6 +42,9 @@ export const searchSpec = { primaryName: thing.name, + color: + thing.color, + additionalNames: (Object.hasOwn(thing, 'additionalNames') ? thing.additionalNames.map(entry => entry.name) @@ -74,6 +77,7 @@ export const searchSpec = { store: [ 'primaryName', 'artwork', + 'color', ], }, |