mirror of
https://github.com/Hackdex-App/hackdex-website.git
synced 2026-10-19 22:28:50 -05:00
Home: sort the Ready shelf by total downloads (#102)
It took the first 12 matching hacks in whatever order the catalog query returned them, which has no order by. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,7 +84,11 @@ export function HomeHero({ catalog }: HeroProps) {
|
||||
export function ReadyShelf({ catalog }: { catalog: HackCardAttributes[] }) {
|
||||
const readyIds = useReadyBaseRomIds();
|
||||
if (readyIds.size === 0) return null;
|
||||
const ready = catalog.filter((h) => h.baseRomId && readyIds.has(h.baseRomId)).slice(0, 12);
|
||||
// Most downloaded first; the catalog itself comes back in no particular order.
|
||||
const ready = catalog
|
||||
.filter((h) => h.baseRomId && readyIds.has(h.baseRomId))
|
||||
.sort((a, b) => b.downloads - a.downloads)
|
||||
.slice(0, 12);
|
||||
const names = [...readyIds].map((id) => baseRoms.find((r) => r.id === id)?.name).filter((n): n is string => Boolean(n));
|
||||
const title = names.length === 1 ? `Ready for your ${baseGameLabel(names[0])}` : "Ready to patch";
|
||||
return <Shelf title={title} blurb="Made for the ROM you linked. Patch any of them now." href="/discover?r=1" hacks={ready} />;
|
||||
|
||||
Reference in New Issue
Block a user