diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f3a3496f0..b2f635e3a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -50,7 +50,7 @@ jobs: uses: actions/upload-artifact@v4 if: failure() with: - name: cypress-screenshots + name: cypress-screenshots-broken-links path: cypress/screenshots test-a11y: @@ -75,7 +75,7 @@ jobs: uses: actions/upload-artifact@v4 if: failure() with: - name: cypress-screenshots + name: cypress-screenshots-a11y path: cypress/screenshots test-seo: @@ -100,5 +100,5 @@ jobs: uses: actions/upload-artifact@v4 if: failure() with: - name: cypress-screenshots + name: cypress-screenshots-seo path: cypress/screenshots diff --git a/cypress/e2e/a11y.cy.ts b/cypress/e2e/a11y.cy.ts index a5813d410..2df1b73e6 100644 --- a/cypress/e2e/a11y.cy.ts +++ b/cypress/e2e/a11y.cy.ts @@ -6,7 +6,7 @@ describe('a11y accessiblity test suite', () => { cy.viewport('macbook-16') cy.visit(page) cy.injectAxe() - cy.wait(500) + cy.wait(100) cy.checkA11y( undefined, { @@ -40,7 +40,7 @@ describe('a11y accessiblity test suite', () => { cy.viewport('iphone-x') cy.visit(page) cy.injectAxe() - cy.wait(500) + cy.wait(100) cy.checkA11y( undefined, { diff --git a/next.config.mjs b/next.config.mjs index ec7724916..38a6d9350 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -87,22 +87,6 @@ const nextConfig = { basePath: false, permanent: true, })), - ...[ - '/docs/local-dashboard', - '/docs/installation', - '/docs/deployment', - '/docs/language-support', - '/docs/guides/deploy', - '/docs/guides/github-actions', - ].map((source) => ({ - source: source, - destination: `/docs/getting-started${source.replace( - /^(\/docs\/guides\/|\/docs\/)/, - '/', - )}`, - basePath: false, - permanent: true, - })), ...['/docs/guides/text-prediction', '/docs/guides/create-histogram'].map( (source) => ({ source: source, @@ -128,7 +112,7 @@ const nextConfig = { }, { source: '/docs/assets', - destination: '/docs/concepts/introduction', + destination: '/docs', basePath: false, permanent: true, }, @@ -140,7 +124,7 @@ const nextConfig = { }, { source: '/docs/concepts', - destination: '/docs/concepts/introduction', + destination: '/docs', basePath: false, permanent: true, }, @@ -164,7 +148,7 @@ const nextConfig = { }, { source: '/docs/access-control', - destination: '/docs/concepts/access-control', + destination: '/docs/get-started/foundations/infrastructure/security', basePath: false, permanent: true, }, @@ -176,25 +160,25 @@ const nextConfig = { }, { source: '/docs/getting-started', - destination: '/docs/getting-started/quickstart', + destination: '/docs/get-started/quickstart', basePath: false, permanent: true, }, { source: '/docs/guides/getting-started', - destination: '/docs/getting-started/quickstart', + destination: '/docs/get-started/quickstart', basePath: false, permanent: true, }, { source: '/docs/guides/getting-started/concepts', - destination: '/docs/concepts/introduction', + destination: '/docs', basePath: false, permanent: true, }, { source: '/docs/getting-started/concepts', - destination: '/docs/concepts/introduction', + destination: '/docs', basePath: false, permanent: true, }, @@ -218,7 +202,7 @@ const nextConfig = { }, { source: '/docs/assets/access-control', - destination: '/docs/concepts/access-control', + destination: '/docs/get-started/foundations/infrastructure/security', basePath: false, permanent: true, }, @@ -236,7 +220,7 @@ const nextConfig = { }, { source: '/docs/guides/getting-started/language-support', - destination: '/docs/concepts/language-support', + destination: '/docs/reference/languages#supported-languages', basePath: false, permanent: true, }, @@ -281,43 +265,36 @@ const nextConfig = { basePath: false, permanent: true, })), - ...[ - '/docs/guides/getting-started/quickstart', - '/docs/guides/getting-started/installation', - '/docs/guides/getting-started/local-dashboard', - '/docs/guides/getting-started/deployment', - ].map((source) => ({ - source: source, - destination: `/docs/${source.replace( - /^(\/docs\/guides\/|\/docs\/)/, - '', - )}`, + { + source: '/docs/guides/getting-started/quickstart', + destination: '/docs/get-started/quickstart', basePath: false, permanent: true, - })), + }, { - source: '/docs/faq/common-questions', - destination: '/docs/faq', + source: '/docs/guides/getting-started/installation', + destination: '/docs/get-started/installation', basePath: false, permanent: true, }, - ...[ - 'aws-cdk', - 'aws-sam', - 'gcp-deployment-manager', - 'bicep', - 'pulumi', - 'terraform', - 'sst', - 'encore', - 'winglang', - 'ampt', - ].map((page) => ({ - source: `/docs/faq/comparison/${page}`, - destination: `/docs/concepts/comparison/${page}`, + { + source: '/docs/guides/getting-started/local-dashboard', + destination: '/docs/get-started/foundations/projects/local-development', basePath: false, permanent: true, - })), + }, + { + source: '/docs/guides/getting-started/deployment', + destination: '/docs/get-started/foundations/deployment', + basePath: false, + permanent: true, + }, + { + source: '/docs/faq/common-questions', + destination: '/docs/faq', + basePath: false, + permanent: true, + }, { source: '/docs/reference/pulumi', destination: '/docs/reference/providers/pulumi', diff --git a/scripts/build-sitemap.js b/scripts/build-sitemap.js index 3550b4c49..f6e50b8f5 100644 --- a/scripts/build-sitemap.js +++ b/scripts/build-sitemap.js @@ -3,8 +3,6 @@ const fs = require('fs/promises') const excludedDirectories = ['[[...slug]]'] // ignore dynamic routes const pages = [] -const URL = 'https://nitric.io/docs' - const readDirRecursive = async (dir) => { const files = await fs.readdir(dir) @@ -14,11 +12,12 @@ const readDirRecursive = async (dir) => { if (stats.isDirectory() && !excludedDirectories.includes(file)) { await readDirRecursive(filePath) } else if (file.startsWith('page.')) { - const loc = `${URL}${filePath + const loc = filePath .replace('src/app', '') .replace('.tsx', '') .replace('.mdx', '') - .replace('page', '')}`.replace(/\/$/, '') + .replace('page', '') + .replace(/\/$/, '') pages.push(loc) } diff --git a/scripts/cypress-fixtures.mjs b/scripts/cypress-fixtures.mjs index 96fad2bda..2e992ec32 100644 --- a/scripts/cypress-fixtures.mjs +++ b/scripts/cypress-fixtures.mjs @@ -4,7 +4,7 @@ import { XMLParser } from 'fast-xml-parser' const parser = new XMLParser() import { allDocs } from '../.contentlayer/generated/index.mjs' -import pages from '../src/assets/sitemap.json' with { type: 'json' } +import basePages from '../src/assets/sitemap.json' with { type: 'json' } const FIXTURE_PATH = 'cypress/fixtures/pages.json' @@ -12,13 +12,15 @@ const PROD_PAGES_PATH = 'cypress/fixtures/prod_pages.json' async function run() { try { - const basePages = pages.map((p) => p.replace('https://nitric.io', '')) + const staticPages = basePages.map((page) => `/docs${page}`) const docPages = allDocs.map((doc) => { return doc.slug === '/' ? '/docs' : `/docs/${doc.slug}` }) - const paths = [...basePages, ...docPages].sort((a, b) => a.localeCompare(b)) + const paths = [...staticPages, ...docPages].sort((a, b) => + a.localeCompare(b), + ) console.log(`${paths.length} paths found. Generating fixture`) diff --git a/src/app/(sitemaps)/sitemap-0.xml/route.ts b/src/app/(sitemaps)/sitemap-0.xml/route.ts index e15ea75d2..f6583e33a 100644 --- a/src/app/(sitemaps)/sitemap-0.xml/route.ts +++ b/src/app/(sitemaps)/sitemap-0.xml/route.ts @@ -1,7 +1,8 @@ import { allDocs } from '@/content' import staticPaths from '@/assets/sitemap.json' +import { BASE_URL } from '@/lib/constants' -const URL = 'https://nitric.io/docs' +const URL = `${BASE_URL}/docs` interface SitemapItem { loc: string @@ -15,7 +16,7 @@ const lastmod = new Date().toISOString() // Function to construct the XML structure of the sitemap index. export async function GET() { const pages = staticPaths.map((page) => ({ - loc: page, + loc: `${URL}${page}`, lastmod, changefreq: 'daily', priority: 0.7, diff --git a/src/app/(sitemaps)/sitemap.xml/route.ts b/src/app/(sitemaps)/sitemap.xml/route.ts index 076746419..1b05fe575 100644 --- a/src/app/(sitemaps)/sitemap.xml/route.ts +++ b/src/app/(sitemaps)/sitemap.xml/route.ts @@ -1,8 +1,8 @@ +import { BASE_URL } from '@/lib/constants' + // Function to construct the XML structure of the sitemap index. export async function GET() { - const sitemapIndexXML = buildSitemapIndex([ - 'https://nitric.io/docs/sitemap-0.xml', - ]) + const sitemapIndexXML = buildSitemapIndex([`${BASE_URL}/docs/sitemap-0.xml`]) // Return the sitemap index XML with the appropriate content type. return new Response(sitemapIndexXML, {