Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit e60167b

Browse files
authored
fix redirect chains (#637)
1 parent 1ab6a5c commit e60167b

File tree

7 files changed

+50
-71
lines changed

7 files changed

+50
-71
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
uses: actions/upload-artifact@v4
5151
if: failure()
5252
with:
53-
name: cypress-screenshots
53+
name: cypress-screenshots-broken-links
5454
path: cypress/screenshots
5555

5656
test-a11y:
@@ -75,7 +75,7 @@ jobs:
7575
uses: actions/upload-artifact@v4
7676
if: failure()
7777
with:
78-
name: cypress-screenshots
78+
name: cypress-screenshots-a11y
7979
path: cypress/screenshots
8080

8181
test-seo:
@@ -100,5 +100,5 @@ jobs:
100100
uses: actions/upload-artifact@v4
101101
if: failure()
102102
with:
103-
name: cypress-screenshots
103+
name: cypress-screenshots-seo
104104
path: cypress/screenshots

cypress/e2e/a11y.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('a11y accessiblity test suite', () => {
66
cy.viewport('macbook-16')
77
cy.visit(page)
88
cy.injectAxe()
9-
cy.wait(500)
9+
cy.wait(100)
1010
cy.checkA11y(
1111
undefined,
1212
{
@@ -40,7 +40,7 @@ describe('a11y accessiblity test suite', () => {
4040
cy.viewport('iphone-x')
4141
cy.visit(page)
4242
cy.injectAxe()
43-
cy.wait(500)
43+
cy.wait(100)
4444
cy.checkA11y(
4545
undefined,
4646
{

next.config.mjs

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,6 @@ const nextConfig = {
8787
basePath: false,
8888
permanent: true,
8989
})),
90-
...[
91-
'/docs/local-dashboard',
92-
'/docs/installation',
93-
'/docs/deployment',
94-
'/docs/language-support',
95-
'/docs/guides/deploy',
96-
'/docs/guides/github-actions',
97-
].map((source) => ({
98-
source: source,
99-
destination: `/docs/getting-started${source.replace(
100-
/^(\/docs\/guides\/|\/docs\/)/,
101-
'/',
102-
)}`,
103-
basePath: false,
104-
permanent: true,
105-
})),
10690
...['/docs/guides/text-prediction', '/docs/guides/create-histogram'].map(
10791
(source) => ({
10892
source: source,
@@ -128,7 +112,7 @@ const nextConfig = {
128112
},
129113
{
130114
source: '/docs/assets',
131-
destination: '/docs/concepts/introduction',
115+
destination: '/docs',
132116
basePath: false,
133117
permanent: true,
134118
},
@@ -140,7 +124,7 @@ const nextConfig = {
140124
},
141125
{
142126
source: '/docs/concepts',
143-
destination: '/docs/concepts/introduction',
127+
destination: '/docs',
144128
basePath: false,
145129
permanent: true,
146130
},
@@ -164,7 +148,7 @@ const nextConfig = {
164148
},
165149
{
166150
source: '/docs/access-control',
167-
destination: '/docs/concepts/access-control',
151+
destination: '/docs/get-started/foundations/infrastructure/security',
168152
basePath: false,
169153
permanent: true,
170154
},
@@ -176,25 +160,25 @@ const nextConfig = {
176160
},
177161
{
178162
source: '/docs/getting-started',
179-
destination: '/docs/getting-started/quickstart',
163+
destination: '/docs/get-started/quickstart',
180164
basePath: false,
181165
permanent: true,
182166
},
183167
{
184168
source: '/docs/guides/getting-started',
185-
destination: '/docs/getting-started/quickstart',
169+
destination: '/docs/get-started/quickstart',
186170
basePath: false,
187171
permanent: true,
188172
},
189173
{
190174
source: '/docs/guides/getting-started/concepts',
191-
destination: '/docs/concepts/introduction',
175+
destination: '/docs',
192176
basePath: false,
193177
permanent: true,
194178
},
195179
{
196180
source: '/docs/getting-started/concepts',
197-
destination: '/docs/concepts/introduction',
181+
destination: '/docs',
198182
basePath: false,
199183
permanent: true,
200184
},
@@ -218,7 +202,7 @@ const nextConfig = {
218202
},
219203
{
220204
source: '/docs/assets/access-control',
221-
destination: '/docs/concepts/access-control',
205+
destination: '/docs/get-started/foundations/infrastructure/security',
222206
basePath: false,
223207
permanent: true,
224208
},
@@ -236,7 +220,7 @@ const nextConfig = {
236220
},
237221
{
238222
source: '/docs/guides/getting-started/language-support',
239-
destination: '/docs/concepts/language-support',
223+
destination: '/docs/reference/languages#supported-languages',
240224
basePath: false,
241225
permanent: true,
242226
},
@@ -281,43 +265,36 @@ const nextConfig = {
281265
basePath: false,
282266
permanent: true,
283267
})),
284-
...[
285-
'/docs/guides/getting-started/quickstart',
286-
'/docs/guides/getting-started/installation',
287-
'/docs/guides/getting-started/local-dashboard',
288-
'/docs/guides/getting-started/deployment',
289-
].map((source) => ({
290-
source: source,
291-
destination: `/docs/${source.replace(
292-
/^(\/docs\/guides\/|\/docs\/)/,
293-
'',
294-
)}`,
268+
{
269+
source: '/docs/guides/getting-started/quickstart',
270+
destination: '/docs/get-started/quickstart',
295271
basePath: false,
296272
permanent: true,
297-
})),
273+
},
298274
{
299-
source: '/docs/faq/common-questions',
300-
destination: '/docs/faq',
275+
source: '/docs/guides/getting-started/installation',
276+
destination: '/docs/get-started/installation',
301277
basePath: false,
302278
permanent: true,
303279
},
304-
...[
305-
'aws-cdk',
306-
'aws-sam',
307-
'gcp-deployment-manager',
308-
'bicep',
309-
'pulumi',
310-
'terraform',
311-
'sst',
312-
'encore',
313-
'winglang',
314-
'ampt',
315-
].map((page) => ({
316-
source: `/docs/faq/comparison/${page}`,
317-
destination: `/docs/concepts/comparison/${page}`,
280+
{
281+
source: '/docs/guides/getting-started/local-dashboard',
282+
destination: '/docs/get-started/foundations/projects/local-development',
318283
basePath: false,
319284
permanent: true,
320-
})),
285+
},
286+
{
287+
source: '/docs/guides/getting-started/deployment',
288+
destination: '/docs/get-started/foundations/deployment',
289+
basePath: false,
290+
permanent: true,
291+
},
292+
{
293+
source: '/docs/faq/common-questions',
294+
destination: '/docs/faq',
295+
basePath: false,
296+
permanent: true,
297+
},
321298
{
322299
source: '/docs/reference/pulumi',
323300
destination: '/docs/reference/providers/pulumi',

scripts/build-sitemap.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const fs = require('fs/promises')
33
const excludedDirectories = ['[[...slug]]'] // ignore dynamic routes
44
const pages = []
55

6-
const URL = 'https://nitric.io/docs'
7-
86
const readDirRecursive = async (dir) => {
97
const files = await fs.readdir(dir)
108

@@ -14,11 +12,12 @@ const readDirRecursive = async (dir) => {
1412
if (stats.isDirectory() && !excludedDirectories.includes(file)) {
1513
await readDirRecursive(filePath)
1614
} else if (file.startsWith('page.')) {
17-
const loc = `${URL}${filePath
15+
const loc = filePath
1816
.replace('src/app', '')
1917
.replace('.tsx', '')
2018
.replace('.mdx', '')
21-
.replace('page', '')}`.replace(/\/$/, '')
19+
.replace('page', '')
20+
.replace(/\/$/, '')
2221

2322
pages.push(loc)
2423
}

scripts/cypress-fixtures.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ import { XMLParser } from 'fast-xml-parser'
44
const parser = new XMLParser()
55

66
import { allDocs } from '../.contentlayer/generated/index.mjs'
7-
import pages from '../src/assets/sitemap.json' with { type: 'json' }
7+
import basePages from '../src/assets/sitemap.json' with { type: 'json' }
88

99
const FIXTURE_PATH = 'cypress/fixtures/pages.json'
1010

1111
const PROD_PAGES_PATH = 'cypress/fixtures/prod_pages.json'
1212

1313
async function run() {
1414
try {
15-
const basePages = pages.map((p) => p.replace('https://nitric.io', ''))
15+
const staticPages = basePages.map((page) => `/docs${page}`)
1616

1717
const docPages = allDocs.map((doc) => {
1818
return doc.slug === '/' ? '/docs' : `/docs/${doc.slug}`
1919
})
2020

21-
const paths = [...basePages, ...docPages].sort((a, b) => a.localeCompare(b))
21+
const paths = [...staticPages, ...docPages].sort((a, b) =>
22+
a.localeCompare(b),
23+
)
2224

2325
console.log(`${paths.length} paths found. Generating fixture`)
2426

src/app/(sitemaps)/sitemap-0.xml/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { allDocs } from '@/content'
22
import staticPaths from '@/assets/sitemap.json'
3+
import { BASE_URL } from '@/lib/constants'
34

4-
const URL = 'https://nitric.io/docs'
5+
const URL = `${BASE_URL}/docs`
56

67
interface SitemapItem {
78
loc: string
@@ -15,7 +16,7 @@ const lastmod = new Date().toISOString()
1516
// Function to construct the XML structure of the sitemap index.
1617
export async function GET() {
1718
const pages = staticPaths.map((page) => ({
18-
loc: page,
19+
loc: `${URL}${page}`,
1920
lastmod,
2021
changefreq: 'daily',
2122
priority: 0.7,

src/app/(sitemaps)/sitemap.xml/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { BASE_URL } from '@/lib/constants'
2+
13
// Function to construct the XML structure of the sitemap index.
24
export async function GET() {
3-
const sitemapIndexXML = buildSitemapIndex([
4-
'https://nitric.io/docs/sitemap-0.xml',
5-
])
5+
const sitemapIndexXML = buildSitemapIndex([`${BASE_URL}/docs/sitemap-0.xml`])
66

77
// Return the sitemap index XML with the appropriate content type.
88
return new Response(sitemapIndexXML, {

0 commit comments

Comments
 (0)