diff --git a/frontend/index.html b/frontend/index.html index 8f52de9c09..513845ebbf 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -37,7 +37,9 @@ script runs before first paint: browsers (JS on) never show the prerender; crawlers without JS still get the full content. Not cloaking — JS-running crawlers see the real app. --> + + + +
diff --git a/frontend/scripts/generate-seo-pages.mjs b/frontend/scripts/generate-seo-pages.mjs index a4bde5ac66..12b640dad0 100644 --- a/frontend/scripts/generate-seo-pages.mjs +++ b/frontend/scripts/generate-seo-pages.mjs @@ -9,6 +9,11 @@ const siteUrl = 'https://commonly.me'; const metadataStart = ''; const metadataEnd = ''; const pageContentMarker = ''; +const gateRuntimeStart = ''; +const gateRuntimeEnd = ''; +const navigationRuntimeStart = ''; +const navigationRuntimeEnd = ''; +const viteEntryAssetPrefix = 'src="/assets/index-'; const escapeHtml = (value) => String(value) .replaceAll('&', '&') @@ -30,6 +35,68 @@ const replaceMarkedSection = (template, start, end, content) => { return `${template.slice(0, startIndex)}${start}\n${content}\n${end}${template.slice(endIndex + end.length)}`; }; +const removeMarkedSection = (template, start, end) => { + const startIndex = template.indexOf(start); + const endIndex = template.indexOf(end); + + if (startIndex < 0 || endIndex < 0 || endIndex < startIndex) { + throw new Error(`Missing or malformed ${start} marker in the Vite output.`); + } + + return `${template.slice(0, startIndex)}${template.slice(endIndex + end.length)}`; +}; + +const removeRuntimeEntryScript = (template) => { + const entryIndex = template.indexOf(viteEntryAssetPrefix); + const tagStart = template.lastIndexOf('<', entryIndex); + const tagEnd = template.indexOf('>', entryIndex); + + if ( + entryIndex < 0 + || tagStart < 0 + || tagEnd < entryIndex + || !template.startsWith(''; const taskManagementHtml = renderStaticPage(guideTemplate, taskManagementGuide); assert.match(taskManagementHtml, /By Commonly · Reviewed by Commonly SEO team/); assert.match(taskManagementHtml, /article:published_time" content="2026-08-25"/); assert.match(taskManagementHtml, /article:modified_time" content="2026-08-25"/); assert.match(taskManagementHtml, /href="\/guides\/multi-agent-collaboration-platform\/"/); assert.match(taskManagementHtml, /href="\/guides\/ai-agent-workspace\/"/); + assert.doesNotMatch(taskManagementHtml, /document\.documentElement/); + assert.doesNotMatch(taskManagementHtml, /popstate/); + assert.doesNotMatch(taskManagementHtml, /modulepreload/); + assert.doesNotMatch(taskManagementHtml, /type="module"/); + assert.doesNotMatch(taskManagementHtml, /src="\/assets\/index-/); + assert.match(taskManagementHtml, /#seo-page \{ color: #fff; \}/); for (const guidePath of [ '/guides/multi-agent-collaboration-platform/', '/guides/ai-agent-workspace/', @@ -81,10 +87,12 @@ test('puts route content, canonical metadata, and structured data in the documen content: '