Naslovnica: razmik po izvajalcu tudi v bloku Beliebt in v featured karuselu
This commit is contained in:
@@ -184,10 +184,10 @@ 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[] {
|
||||
function razmakniPoIzvajalcu(list: Article[], razmik = 5, seed: string[] = []): Article[] {
|
||||
const rest = [...(list || [])];
|
||||
const out: Article[] = [];
|
||||
const recent: string[] = [];
|
||||
const recent: string[] = seed.filter(Boolean).slice(-(razmik - 1));
|
||||
while (rest.length) {
|
||||
let idx = rest.findIndex((a) => {
|
||||
const k = artistKey(a?.title || "");
|
||||
@@ -261,7 +261,12 @@ function MobileMosaic({ latest, popular, focalPoints }: { latest: Article[]; pop
|
||||
if (l.length === 0) return null;
|
||||
|
||||
const usedIds = new Set(pool.map((a) => a.id));
|
||||
const p = (popular || []).filter((a) => !usedIds.has(a.id)).slice(0, 3);
|
||||
const seenNow = l.map((a) => artistKey(a?.title || "")).filter(Boolean);
|
||||
const p = razmakniPoIzvajalcu(
|
||||
(popular || []).filter((a) => !usedIds.has(a.id)),
|
||||
5,
|
||||
seenNow,
|
||||
).slice(0, 3);
|
||||
|
||||
const nextStart = ((displayPage + 1) % totalPages) * pageSize;
|
||||
const preload = pool.slice(nextStart, nextStart + pageSize);
|
||||
@@ -949,7 +954,7 @@ export default function Home() {
|
||||
pod karuselom je zato ostal prazen pas. Zdaj se karusel
|
||||
raztegne do visine stranskega stolpca. */}
|
||||
<div className="hidden md:block lg:flex-1 lg:min-h-0">
|
||||
<FeaturedCarousel articles={articles.filter(a => a.featured)} popular={popular} galleryImages={galleryImages} focalPoints={focalPoints} />
|
||||
<FeaturedCarousel articles={razmakniPoIzvajalcu(articles.filter(a => a.featured))} popular={popular} galleryImages={galleryImages} focalPoints={focalPoints} />
|
||||
</div>
|
||||
<MobileMosaic
|
||||
latest={[...articles].sort((a, b) => new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime())}
|
||||
|
||||
Reference in New Issue
Block a user