mreza brez praznih celic (samo polne vrstice po stiri) in relativni cas namesto ISO znacke v bloku Aktuelle Nachrichten

This commit is contained in:
2026-08-31 12:48:15 +02:00
parent cdf45b9933
commit 7a25bf73cf
2 changed files with 19 additions and 3 deletions
+15 -1
View File
@@ -1059,6 +1059,20 @@ export async function registerRoutes(
}
});
// Blok pricakuje ze izpisan relativni cas, kakrsnega je prej vracal RSS
// parser; brez tega se izpise gola ISO znacka.
function relativniCas(iso?: string): string {
if (!iso) return "";
const t = new Date(iso).getTime();
if (!t) return "";
const min = Math.max(0, Math.floor((Date.now() - t) / 60000));
if (min < 2) return "Gerade eben";
if (min < 60) return `vor ${min} Min.`;
const ur = Math.floor(min / 60);
if (ur < 24) return `vor ${ur} Std.`;
return `vor ${Math.floor(ur / 24)} T.`;
}
app.get("/api/breaking-news", async (_req, res) => {
// 31. 8. 2026: blok Aktuelle Nachrichten je vodil na tagesschau, n-tv, ORF
// in Welt, torej smo obiskovalce posiljali s strani. Zdaj kaze nase novice
@@ -1102,7 +1116,7 @@ export async function registerRoutes(
title: String(a.title),
link: `https://news.folx.tv/${a.slug}`,
source: String(a.category || "FOLX NEWS"),
pubDate: String(a.publishedAt || ""),
pubDate: relativniCas(a.publishedAt),
}));
if (items.length > 0) setCache(cacheKey, items);
res.json(items);