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

View File

@ -82,6 +82,11 @@ export async function registerRoutes(
});
// ---- SEO: robots.txt, sitemap.xml, news sitemap, RSS ----
// Rubrike z onemusic.news imajo isto besedilo kot tam, zato jih ne oddajamo
// Googlu. V bazi in v /api/articles ostanejo — sidebar na TV jih potrebuje.
const ONE_RUBRIKEN = new Set(["Politik", "Promis", "Sport", "Musik & Film", "Wetter", "Finanzen", "Aktuelles"]);
const isOwn = (a: any) => !ONE_RUBRIKEN.has(a?.category || "");
const SITE = "https://folx.tv";
const xmlEscape = (s: string) =>
String(s || "")
@ -113,6 +118,7 @@ export async function registerRoutes(
urls.push(` <url>\n <loc>${SITE}${p}</loc>\n <changefreq>daily</changefreq>\n <priority>${p === "/" ? "1.0" : "0.7"}</priority>\n </url>`);
}
for (const a of articles) {
if (!isOwn(a)) continue;
const lastmod = a.publishedAt ? new Date(a.publishedAt as any).toISOString() : new Date().toISOString();
urls.push(` <url>\n <loc>${SITE}/article/${xmlEscape(a.slug)}</loc>\n <lastmod>${lastmod}</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>`);
}
@ -129,6 +135,7 @@ export async function registerRoutes(
const now = Date.now();
const twoDays = 48 * 60 * 60 * 1000;
const recent = articles.filter((a) => {
if (!isOwn(a)) return false;
const t = a.publishedAt ? new Date(a.publishedAt as any).getTime() : now;
return now - t <= twoDays;
});

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;
}