Rubrike z onemusic.news dobijo noindex in gredo iz sitemapov; v API in na TV sidebar ostanejo
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user