Build Mission Core promo, product knowledge and original media

This commit is contained in:
Codex
2026-11-04 21:34:55 +03:00
parent 309ea4dc07
commit 132a06754b
64 changed files with 7415 additions and 10367 deletions
+17 -1
View File
@@ -172,7 +172,7 @@ function renderKnowledgeShortcodes(html) {
}
function canonicalHome() {
const fallback = "https://nodedc.dctouch.ru/";
const fallback = "https://nodedc.ru/";
const value = String(home.seo?.canonicalUrl || fallback).trim() || fallback;
try {
@@ -766,4 +766,20 @@ for (const record of records) {
}
await writeSeoFiles(records);
// Replace legacy business pages on incremental hosting uploads as well.
// Redirects are separate from the editable knowledge tree and its sitemap.
const redirects = JSON.parse(await readFile(join(repoRoot, "content", "redirects.json"), "utf8").catch(error => {
if (error.code === "ENOENT") return "{}";
throw error;
}));
const rules = [];
for (const [from, to] of Object.entries(redirects)) {
if (!/^\/(?:[a-z0-9-]+\/)+$/.test(from) || !/^\/knowledge\/(?:[a-z0-9-]+\/)*$/.test(to) || from === to) {
throw new Error(`Invalid redirect: ${from} → ${to}`);
}
if (records.some(record => record.urlPath === from)) throw new Error(`Redirect replaces an active article: ${from}`);
await writePage(from, `<!doctype html><html lang="ru"><meta charset="utf-8"><meta name="robots" content="noindex,follow"><meta http-equiv="refresh" content="0;url=${to}"><link rel="canonical" href="${canonicalForPath(to)}"><title>Mission Core</title><p><a href="${to}">Перейти к материалам Mission Core</a></p></html>`);
rules.push(`RedirectMatch 301 ^${from}(?:index\\.html)?$ ${to}`);
}
await writeFile(join(repoRoot, ".htaccess"), `# Generated legacy URL redirects\n${rules.join("\n")}\n`);
console.log(`Rendered ${records.length + 1} knowledge pages -> /${knowledgeBasePath()}/`);