diff --git a/server/static.ts b/server/static.ts index 015c4e7..1ea7b7f 100644 --- a/server/static.ts +++ b/server/static.ts @@ -182,6 +182,24 @@ export function serveStatic(app: Express) { res.status(200).set({ "Content-Type": "text/html" }).end(template); return; } + + // Clanka s tem slugom ni. Brez tega bi SPA vrnil HTTP 200 z naslovnico + // in canonical na "/" — Google to bere kot podvojeno naslovnico (soft 404), + // izbrisani clanki pa ostanejo v indeksu in v Discovru. + { + let template = await fs.promises.readFile(indexPath, "utf-8"); + template = stripExistingMeta(template); + template = template.replace( + /[^<]*<\/title>/, + [ + '<meta name="robots" content="noindex, follow" />', + '<meta name="description" content="Dieser Artikel ist nicht mehr verfuegbar." />', + '<title>Artikel nicht gefunden | Folx Music Television', + ].join("\n "), + ); + res.status(404).set({ "Content-Type": "text/html" }).end(template); + return; + } } catch (e) { } }