fix: Recent SKUs

This commit is contained in:
Brennan Wilkes (Text Groove) 2026-01-20 16:29:04 -08:00
parent be5fd437ff
commit da13f919bf

View file

@ -157,16 +157,22 @@ export function renderSearch($app) {
const when = r.ts ? prettyTs(r.ts) : r.date || ""; const when = r.ts ? prettyTs(r.ts) : r.date || "";
const rawSku = String(r.sku || ""); const rawSku = String(r.sku || "");
const sku = canon(rawSku); const sku = canon(rawSku);
const img = aggBySku.get(sku)?.img || "";
const agg = aggBySku.get(sku) || null;
const img = agg?.img || "";
// show "+N" if the canonical SKU exists in other stores (via SKU mapping)
const storeCount = agg?.stores?.size || 0;
const plus = storeCount > 1 ? ` +${storeCount - 1}` : "";
const href = String(r.url || "").trim(); const href = String(r.url || "").trim();
const storeBadge = href const storeBadge = href
? `<a class="badge" href="${esc( ? `<a class="badge" href="${esc(
href href
)}" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()">${esc( )}" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()">${esc(
r.storeLabel || "" (r.storeLabel || "") + plus
)}</a>` )}</a>`
: `<span class="badge">${esc(r.storeLabel || "")}</span>`; : `<span class="badge">${esc((r.storeLabel || "") + plus)}</span>`;
// date as a badge so it sits nicely in the single meta row // date as a badge so it sits nicely in the single meta row
const dateBadge = when ? `<span class="badge mono">${esc(when)}</span>` : ""; const dateBadge = when ? `<span class="badge mono">${esc(when)}</span>` : "";