Naslovnica: razmik po skupini izvajalca (Rier = Kastelruther Spatzen), Beliebt brez podvojitev iz bazena

This commit is contained in:
folx bot
2026-08-29 20:34:27 +02:00
parent 12694d6db8
commit 85e7a1e7c7
4 changed files with 48 additions and 15 deletions
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { artistKey } from "@/lib/artists"; import { artistGroup } from "@/lib/artists";
import { useState, useEffect, useCallback } from "react"; import { useState, useEffect, useCallback } from "react";
import { Globe, ExternalLink } from "lucide-react"; import { Globe, ExternalLink } from "lucide-react";
@@ -27,13 +27,13 @@ export function BreakingNewsWidget() {
const recent: string[] = []; const recent: string[] = [];
while (rest.length) { while (rest.length) {
let idx = rest.findIndex((n: any) => { let idx = rest.findIndex((n: any) => {
const k = artistKey(n?.title || ""); const k = artistGroup(n?.title || "");
return !k || !recent.includes(k); return !k || !recent.includes(k);
}); });
if (idx < 0) idx = 0; if (idx < 0) idx = 0;
const n = rest.splice(idx, 1)[0]; const n = rest.splice(idx, 1)[0];
out.push(n); out.push(n);
recent.push(artistKey((n as any)?.title || "")); recent.push(artistGroup((n as any)?.title || ""));
if (recent.length >= 5) recent.shift(); if (recent.length >= 5) recent.shift();
} }
return out; return out;
+3 -3
View File
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { artistKey } from "@/lib/artists"; import { artistGroup } from "@/lib/artists";
import { useState, useEffect, useCallback } from "react"; import { useState, useEffect, useCallback } from "react";
import { Newspaper, ExternalLink } from "lucide-react"; import { Newspaper, ExternalLink } from "lucide-react";
@@ -27,13 +27,13 @@ export function NewsWidget() {
const recent: string[] = []; const recent: string[] = [];
while (rest.length) { while (rest.length) {
let idx = rest.findIndex((n: any) => { let idx = rest.findIndex((n: any) => {
const k = artistKey(n?.title || ""); const k = artistGroup(n?.title || "");
return !k || !recent.includes(k); return !k || !recent.includes(k);
}); });
if (idx < 0) idx = 0; if (idx < 0) idx = 0;
const n = rest.splice(idx, 1)[0]; const n = rest.splice(idx, 1)[0];
out.push(n); out.push(n);
recent.push(artistKey((n as any)?.title || "")); recent.push(artistGroup((n as any)?.title || ""));
if (recent.length >= 5) recent.shift(); if (recent.length >= 5) recent.shift();
} }
return out; return out;
+30
View File
@@ -159,3 +159,33 @@ export function artistKey(title: string): string {
} }
return best ? norm(best) : ""; return best ? norm(best) : "";
} }
/** Rocne povezave: druzine in zasedbe, ki spadajo skupaj. */
const SKUPINE: Record<string, string> = {
"alexander rier": "kastelruther spatzen",
"norbert rier": "kastelruther spatzen",
"kastelruther spatzen": "kastelruther spatzen",
};
/** Druga beseda, ki ni priimek in zato ne sme delati skupine. */
const NI_PRIIMEK = new Set([
"schlager", "music", "band", "express", "quintett", "brothers",
"oberkrainer", "buam", "boys", "girls", "sisters",
]);
/**
* Skupina izvajalca za razmik na naslovnici. Alexander in Norbert Rier sta ista
* skupina (Kastelruther Spatzen), prav tako Costa in Lucas Cordalis ali sestri
* Hofmann - dva taka clanka drug ob drugem bralcu izgledata kot podvojitev.
*/
export function artistGroup(title: string): string {
const k = artistKey(title);
if (!k) return "";
if (SKUPINE[k]) return SKUPINE[k];
if (k.includes('"')) return k;
const d = k.split(" ");
if (d.length === 2 && !/^(die|das|der|dj)$/.test(d[0]) && d[1].length >= 4 && !NI_PRIIMEK.has(d[1])) {
return d[1];
}
return k;
}
+12 -9
View File
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { artistKey } from "@/lib/artists"; import { artistGroup } from "@/lib/artists";
import { Link } from "wouter"; import { Link } from "wouter";
import { type Article } from "@shared/schema"; import { type Article } from "@shared/schema";
import { format } from "date-fns"; import { format } from "date-fns";
@@ -190,13 +190,13 @@ function razmakniPoIzvajalcu(list: Article[], razmik = 5, seed: string[] = []):
const recent: string[] = seed.filter(Boolean).slice(-(razmik - 1)); const recent: string[] = seed.filter(Boolean).slice(-(razmik - 1));
while (rest.length) { while (rest.length) {
let idx = rest.findIndex((a) => { let idx = rest.findIndex((a) => {
const k = artistKey(a?.title || ""); const k = artistGroup(a?.title || "");
return !k || !recent.includes(k); return !k || !recent.includes(k);
}); });
if (idx < 0) idx = 0; if (idx < 0) idx = 0;
const a = rest.splice(idx, 1)[0]; const a = rest.splice(idx, 1)[0];
out.push(a); out.push(a);
recent.push(artistKey(a?.title || "")); recent.push(artistGroup(a?.title || ""));
if (recent.length >= razmik) recent.shift(); if (recent.length >= razmik) recent.shift();
} }
return out; return out;
@@ -261,11 +261,14 @@ function MobileMosaic({ latest, popular, focalPoints }: { latest: Article[]; pop
if (l.length === 0) return null; if (l.length === 0) return null;
const usedIds = new Set(pool.map((a) => a.id)); const usedIds = new Set(pool.map((a) => a.id));
const seenNow = l.map((a) => artistKey(a?.title || "")).filter(Boolean); const poolGroups = new Set(pool.map((a) => artistGroup(a?.title || "")).filter(Boolean));
const kandidati = (popular || []).filter((a) => !usedIds.has(a.id));
const brezPodvojitve = kandidati.filter((a) => {
const g = artistGroup(a?.title || "");
return !g || !poolGroups.has(g);
});
const p = razmakniPoIzvajalcu( const p = razmakniPoIzvajalcu(
(popular || []).filter((a) => !usedIds.has(a.id)), brezPodvojitve.length >= 3 ? brezPodvojitve : kandidati,
5,
seenNow,
).slice(0, 3); ).slice(0, 3);
const nextStart = ((displayPage + 1) % totalPages) * pageSize; const nextStart = ((displayPage + 1) % totalPages) * pageSize;
@@ -806,13 +809,13 @@ export default function Home() {
const recent: string[] = []; const recent: string[] = [];
while (rest.length) { while (rest.length) {
let idx = rest.findIndex((a) => { let idx = rest.findIndex((a) => {
const k = artistKey(a.title || ""); const k = artistGroup(a.title || "");
return !k || !recent.includes(k); return !k || !recent.includes(k);
}); });
if (idx < 0) idx = 0; if (idx < 0) idx = 0;
const a = rest.splice(idx, 1)[0]; const a = rest.splice(idx, 1)[0];
out.push(a); out.push(a);
recent.push(artistKey(a.title || "")); recent.push(artistGroup(a.title || ""));
if (recent.length >= RAZMIK) recent.shift(); if (recent.length >= RAZMIK) recent.shift();
} }
return out; return out;