diff --git a/scripts/create-testenv.mjs b/scripts/create-testenv.mjs index 3ff734b1..b2fd2cf4 100644 --- a/scripts/create-testenv.mjs +++ b/scripts/create-testenv.mjs @@ -25,6 +25,7 @@ const ROOT_PAGE_CANONICALS = { 'app.html': `${TESTENV_CANONICAL_SITE_URL}/app.html`, 'generator.html': `${TESTENV_CANONICAL_SITE_URL}/generator.html`, 'combinatorial.html': `${TESTENV_CANONICAL_SITE_URL}/combinatorial.html`, + 'webmcp.html': `${TESTENV_CANONICAL_SITE_URL}/webmcp.html`, }; const TESTENV_INDICATOR_STYLE = ``; function hideTopHeaderInBuiltHtml(html) { - if (html.includes('data-testenv-hide-header')) { - return html; - } + return upsertHeadStyle(html, 'data-testenv-hide-header', TESTENV_HIDE_HEADER_STYLE); +} - return html.replace('', `${TESTENV_HIDE_HEADER_STYLE}\n `); +function applyTopHeaderHideToHtml(html) { + return hideTopHeaderInBuiltHtml(html); } async function hideTopHeaderInBuiltPage(pagePath) { @@ -507,7 +509,6 @@ async function hideTopHeaderInBuiltPage(pagePath) { if (nextHtml === html) { return; } - await writeFile(pagePath, nextHtml, 'utf8'); } @@ -575,6 +576,7 @@ async function main() { await hideTopHeaderInBuiltPage(path.join(outputDir, 'app.html')); await hideTopHeaderInBuiltPage(path.join(outputDir, 'generator.html')); await hideTopHeaderInBuiltPage(path.join(outputDir, 'combinatorial.html')); + await hideTopHeaderInBuiltPage(path.join(outputDir, 'webmcp.html')); await mkdir(fullSiteDir, { recursive: true }); await createTemporaryDocsAppPlaceholder(); @@ -593,6 +595,18 @@ async function main() { } await copyWebBuildIntoDirectory(tempWebDir, fullSiteDir); + await applySeoDirectivesToFile(path.join(fullSiteDir, 'app.html'), { + canonicalUrl: ROOT_PAGE_CANONICALS['app.html'], + }); + await applySeoDirectivesToFile(path.join(fullSiteDir, 'generator.html'), { + canonicalUrl: ROOT_PAGE_CANONICALS['generator.html'], + }); + await applySeoDirectivesToFile(path.join(fullSiteDir, 'combinatorial.html'), { + canonicalUrl: ROOT_PAGE_CANONICALS['combinatorial.html'], + }); + await applySeoDirectivesToFile(path.join(fullSiteDir, 'webmcp.html'), { + canonicalUrl: ROOT_PAGE_CANONICALS['webmcp.html'], + }); await rm(tempWebDir, { recursive: true, force: true, @@ -619,6 +633,7 @@ export { TESTENV_CANONICAL_SITE_URL, TESTENV_ROBOTS_DIRECTIVES, applySeoDirectivesToHtml, + applyTopHeaderHideToHtml, createLlmsTxt, createSiteRobotsTxt, createTestenvRobotsTxt, diff --git a/tests/integration/create-testenv-seo.test.js b/tests/integration/create-testenv-seo.test.js index 71d5f079..0c972eca 100644 --- a/tests/integration/create-testenv-seo.test.js +++ b/tests/integration/create-testenv-seo.test.js @@ -2,6 +2,7 @@ import { ROOT_CANONICAL_URL, TESTENV_CANONICAL_SITE_URL, applySeoDirectivesToHtml, + applyTopHeaderHideToHtml, createLlmsTxt, createSiteRobotsTxt, createTestenvRobotsTxt, @@ -30,6 +31,7 @@ describe('create-testenv SEO helpers', () => { expect(llmsTxt).toContain('non-production review and test deployment'); expect(llmsTxt).toContain(ROOT_CANONICAL_URL); + expect(llmsTxt).toContain(`${TESTENV_CANONICAL_SITE_URL}/webmcp.html`); expect(llmsTxt).toContain(`${TESTENV_CANONICAL_SITE_URL}/docs/`); }); @@ -99,4 +101,32 @@ describe('create-testenv SEO helpers', () => { expect(html).toContain('.header {'); expect(html).toContain('display: none !important;'); }); + + test('adds the testenv header-hiding style for top-level published app pages', () => { + const html = applyTopHeaderHideToHtml('