From aacf46d52301a1f30fd777699d58537a3e72c912 Mon Sep 17 00:00:00 2001 From: FOLX Claude Date: Sat, 29 Aug 2026 19:43:47 +0200 Subject: [PATCH] Neueste Artikel in Top Stories: isti izvajalec vsaj 5 mest narazen --- client/src/pages/home.tsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx index 588d3f5..dec06cf 100644 --- a/client/src/pages/home.tsx +++ b/client/src/pages/home.tsx @@ -183,9 +183,28 @@ function MosaicHeading({ children }: { children: React.ReactNode }) { ); } +/** Isti izvajalec ne sme stati drug ob drugem: med dvema clankoma vsaj 5 mest. */ +function razmakniPoIzvajalcu(list: Article[], razmik = 5): Article[] { + const rest = [...(list || [])]; + const out: Article[] = []; + const recent: string[] = []; + while (rest.length) { + let idx = rest.findIndex((a) => { + const k = artistKey(a?.title || ""); + return !k || !recent.includes(k); + }); + if (idx < 0) idx = 0; + const a = rest.splice(idx, 1)[0]; + out.push(a); + recent.push(artistKey(a?.title || "")); + if (recent.length >= razmik) recent.shift(); + } + return out; +} + function MobileMosaic({ latest, popular, focalPoints }: { latest: Article[]; popular?: Article[]; focalPoints?: Record }) { const pageSize = 3; - const pool = (latest || []).slice(0, 9); + const pool = razmakniPoIzvajalcu(latest || []).slice(0, 9); const totalPages = Math.max(1, Math.ceil(pool.length / pageSize)); const [page, setPage] = useState(0); @@ -940,7 +959,7 @@ export default function Home() {
- {articles && articles.length > 0 && new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime()).slice(0, 8)} className="lg:flex-1 lg:min-h-0 overflow-hidden" />} + {articles && articles.length > 0 && new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime())).slice(0, 8)} className="lg:flex-1 lg:min-h-0 overflow-hidden" />}