Rubrike z onemusic.news dobijo noindex in gredo iz sitemapov; v API in na TV sidebar ostanejo

This commit is contained in:
FOLX Bot
2026-08-17 20:14:31 +02:00
parent 160994f531
commit df15293ea3
2 changed files with 24 additions and 0 deletions
+17
View File
@@ -25,6 +25,19 @@ function ogImageUrl(coverImage: string, baseUrl: string): string {
return imgPath.startsWith("http") ? imgPath : `${baseUrl}${imgPath}`;
}
// Rubrike, ki jih pisemo enkrat in objavimo tudi na onemusic.news. Besedilo je
// isto na obeh domenah, zato jih na folx.tv drzimo zunaj Googlovega indeksa —
// v bazi in v /api/articles ostanejo, ker jih bere sidebar na TV kanalih.
const ONE_RUBRIKEN = new Set(["Politik", "Promis", "Sport", "Musik & Film", "Wetter", "Finanzen", "Aktuelles"]);
function setRobots(html: string, content: string): string {
const tag = `<meta name="robots" content="${content}" />`;
if (/<meta\s+name="robots"[^>]*>/i.test(html)) {
return html.replace(/<meta\s+name="robots"[^>]*>/i, tag);
}
return html.replace("</head>", ` ${tag}\n </head>`);
}
function stripExistingMeta(html: string): string {
html = html.replace(/<meta\s+property="og:[^"]*"[^>]*>\s*/gi, "");
html = html.replace(/<meta\s+name="twitter:[^"]*"[^>]*>\s*/gi, "");
@@ -179,6 +192,10 @@ export function serveStatic(app: Express) {
].join("\n");
template = template.replace('<div id="root"></div>', () => `<div id="root">${ssrBlock}</div>`);
if (ONE_RUBRIKEN.has(article.category || "")) {
template = setRobots(template, "noindex, follow, max-image-preview:large");
}
res.status(200).set({ "Content-Type": "text/html" }).end(template);
return;
}