Skip to content

Commit 1443037

Browse files
committed
feat: new routing schema - updated cache routes, docs and tests
1 parent 4972d0e commit 1443037

File tree

10 files changed

+80
-78
lines changed

10 files changed

+80
-78
lines changed

docs/content/2.guide/1.features.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ Quick access to online development environments detected from package READMEs:
9292

9393
### Custom badges
9494

95-
You can add custom npmx badges to your markdown files using the following syntax: `[![Open on npmx.dev](https://npmx.dev/api/registry/badge/YOUR_PACKAGE)](https://npmx.dev/YOUR_PACKAGE)`
95+
You can add custom npmx badges to your markdown files using the following syntax: `[![Open on npmx.dev](https://npmx.dev/api/registry/badge/YOUR_PACKAGE)](https://npmx.dev/package/YOUR_PACKAGE)`
9696

9797
Do not forget to replace `YOUR_PACKAGE` with the actual package name.
9898

9999
Here are some examples:
100100

101101
```
102102
# Default
103-
[![Open on npmx.dev](https://npmx.dev/api/registry/badge/nuxt)](https://npmx.dev/nuxt)
103+
[![Open on npmx.dev](https://npmx.dev/api/registry/badge/nuxt)](https://npmx.dev/package/nuxt)
104104
105105
# Organization packages
106-
[![Open on npmx.dev](https://npmx.dev/api/registry/badge/@nuxt/kit)](https://npmx.dev/@nuxt/kit)
106+
[![Open on npmx.dev](https://npmx.dev/api/registry/badge/@nuxt/kit)](https://npmx.dev/package/@nuxt/kit)
107107
108108
# Version-specific badges
109-
[![Open on npmx.dev](https://npmx.dev/api/registry/badge/nuxt/v/3.12.0)](https://npmx.dev/nuxt/v/3.12.0)
109+
[![Open on npmx.dev](https://npmx.dev/api/registry/badge/nuxt/v/3.12.0)](https://npmx.dev/package/nuxt/v/3.12.0)
110110
```

nuxt.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ export default defineNuxtConfig({
9999
'/search': { isr: false, cache: false },
100100
'/api/auth/**': { isr: false, cache: false },
101101
// infinite cache (versioned - doesn't change)
102-
'/code/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
103-
'/docs/:pkg/v/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
104-
'/docs/:scope/:pkg/v/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
102+
'/package-code/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
103+
'/package-docs/:pkg/v/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
104+
'/package-docs/:scope/:pkg/v/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
105105
'/api/registry/docs/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
106106
'/api/registry/file/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },
107107
'/api/registry/files/**': { isr: true, cache: { maxAge: 365 * 24 * 60 * 60 } },

test/e2e/create-command.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test.describe('Create Command', () => {
66

77
test.describe('Visibility', () => {
88
test('/vite - should show create command (same maintainers)', async ({ page, goto }) => {
9-
await goto('/vite', { waitUntil: 'domcontentloaded' })
9+
await goto('/package/vite', { waitUntil: 'domcontentloaded' })
1010

1111
// Create command section should be visible (SSR)
1212
// Use specific container to avoid matching README code blocks
@@ -15,14 +15,14 @@ test.describe('Create Command', () => {
1515
await expect(createCommandSection.locator('code')).toContainText(/create vite/i)
1616

1717
// Link to create-vite should be present (uses sr-only text, so check attachment not visibility)
18-
await expect(page.locator('a[href="/create-vite"]').first()).toBeAttached()
18+
await expect(page.locator('a[href="/package/create-vite"]').first()).toBeAttached()
1919
})
2020

2121
test('/next - should show create command (shared maintainer, same repo)', async ({
2222
page,
2323
goto,
2424
}) => {
25-
await goto('/next', { waitUntil: 'domcontentloaded' })
25+
await goto('/package/next', { waitUntil: 'domcontentloaded' })
2626

2727
// Create command section should be visible (SSR)
2828
// Use specific container to avoid matching README code blocks
@@ -31,14 +31,14 @@ test.describe('Create Command', () => {
3131
await expect(createCommandSection.locator('code')).toContainText(/create next-app/i)
3232

3333
// Link to create-next-app should be present (uses sr-only text, so check attachment not visibility)
34-
await expect(page.locator('a[href="/create-next-app"]').first()).toBeAttached()
34+
await expect(page.locator('a[href="/package/create-next-app"]').first()).toBeAttached()
3535
})
3636

3737
test('/nuxt - should show create command (same maintainer, same org)', async ({
3838
page,
3939
goto,
4040
}) => {
41-
await goto('/nuxt', { waitUntil: 'domcontentloaded' })
41+
await goto('/package/nuxt', { waitUntil: 'domcontentloaded' })
4242

4343
// Create command section should be visible (SSR)
4444
// nuxt has create-nuxt package, so command is "npm create nuxt"
@@ -52,7 +52,7 @@ test.describe('Create Command', () => {
5252
page,
5353
goto,
5454
}) => {
55-
await goto('/color', { waitUntil: 'domcontentloaded' })
55+
await goto('/package/color', { waitUntil: 'domcontentloaded' })
5656

5757
// Wait for package to load
5858
await expect(page.locator('h1').filter({ hasText: 'color' })).toBeVisible()
@@ -67,7 +67,7 @@ test.describe('Create Command', () => {
6767
page,
6868
goto,
6969
}) => {
70-
await goto('/lodash', { waitUntil: 'domcontentloaded' })
70+
await goto('/package/lodash', { waitUntil: 'domcontentloaded' })
7171

7272
// Wait for package to load
7373
await expect(page.locator('h1').filter({ hasText: 'lodash' })).toBeVisible()
@@ -81,7 +81,7 @@ test.describe('Create Command', () => {
8181

8282
test.describe('Copy Functionality', () => {
8383
test('hovering create command shows copy button', async ({ page, goto }) => {
84-
await goto('/vite', { waitUntil: 'hydration' })
84+
await goto('/package/vite', { waitUntil: 'hydration' })
8585

8686
await expect(page.locator('h1')).toContainText('vite', { timeout: 15000 })
8787

@@ -112,7 +112,7 @@ test.describe('Create Command', () => {
112112
// Grant clipboard permissions
113113
await context.grantPermissions(['clipboard-read', 'clipboard-write'])
114114

115-
await goto('/vite', { waitUntil: 'hydration' })
115+
await goto('/package/vite', { waitUntil: 'hydration' })
116116
await expect(page.locator('h1')).toContainText('vite', { timeout: 15000 })
117117

118118
await expect(page.locator('main header').locator('text=/v\\d+\\.\\d+/')).toBeVisible({
@@ -142,7 +142,7 @@ test.describe('Create Command', () => {
142142

143143
test.describe('Install Command Copy', () => {
144144
test('hovering install command shows copy button', async ({ page, goto }) => {
145-
await goto('/lodash', { waitUntil: 'hydration' })
145+
await goto('/package/lodash', { waitUntil: 'hydration' })
146146

147147
// Find the install command container
148148
const installCommandContainer = page.locator('.group\\/installcmd').first()
@@ -167,7 +167,7 @@ test.describe('Create Command', () => {
167167
// Grant clipboard permissions
168168
await context.grantPermissions(['clipboard-read', 'clipboard-write'])
169169

170-
await goto('/lodash', { waitUntil: 'hydration' })
170+
await goto('/package/lodash', { waitUntil: 'hydration' })
171171

172172
// Find and hover over the install command container
173173
const installCommandContainer = page.locator('.group\\/installcmd').first()

test/e2e/docs.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@nuxt/test-utils/playwright'
33
test.describe('API Documentation Pages', () => {
44
test('docs page loads and shows content for a package', async ({ page, goto }) => {
55
// Use a small, stable package with TypeScript types
6-
await goto('/docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
6+
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
77

88
// Page title should include package name
99
await expect(page).toHaveTitle(/ufo.*docs/i)
@@ -24,7 +24,7 @@ test.describe('API Documentation Pages', () => {
2424
})
2525

2626
test('docs page shows TOC sidebar on desktop', async ({ page, goto }) => {
27-
await goto('/docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
27+
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
2828

2929
// TOC sidebar should be visible (on desktop viewport)
3030
const tocSidebar = page.locator('aside')
@@ -38,7 +38,7 @@ test.describe('API Documentation Pages', () => {
3838
})
3939

4040
test('TOC links navigate to sections', async ({ page, goto }) => {
41-
await goto('/docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
41+
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
4242

4343
// Click on Functions in TOC
4444
const functionsLink = page.locator('aside a[href="#section-function"]')
@@ -53,7 +53,7 @@ test.describe('API Documentation Pages', () => {
5353
})
5454

5555
test('clicking symbol name scrolls to symbol', async ({ page, goto }) => {
56-
await goto('/docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
56+
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
5757

5858
// Find a symbol link in the TOC
5959
const symbolLink = page.locator('aside a[href^="#function-"]').first()
@@ -67,14 +67,14 @@ test.describe('API Documentation Pages', () => {
6767
})
6868

6969
test('docs page without version redirects to latest', async ({ page, goto }) => {
70-
await goto('/docs/ufo', { waitUntil: 'networkidle' })
70+
await goto('/package-docs/ufo', { waitUntil: 'networkidle' })
7171

7272
// Should redirect to include version
7373
await expect(page).toHaveURL(/\/docs\/ufo\/v\//)
7474
})
7575

7676
test('package link in header navigates to package page', async ({ page, goto }) => {
77-
await goto('/docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
77+
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
7878

7979
// Click on package name in header
8080
const packageLink = page.locator('header a').filter({ hasText: 'ufo' })
@@ -87,7 +87,7 @@ test.describe('API Documentation Pages', () => {
8787
test('docs page handles package gracefully when types unavailable', async ({ page, goto }) => {
8888
// Use a simple JS package - the page should load without crashing
8989
// regardless of whether it has types or shows an error state
90-
await goto('/docs/is-odd/v/3.0.1', { waitUntil: 'networkidle' })
90+
await goto('/package-docs/is-odd/v/3.0.1', { waitUntil: 'networkidle' })
9191

9292
// Header should always show the package name
9393
await expect(page.locator('header').getByText('is-odd')).toBeVisible()
@@ -105,7 +105,7 @@ test.describe('API Documentation Pages', () => {
105105

106106
test.describe('Version Selector', () => {
107107
test('version selector dropdown shows versions', async ({ page, goto }) => {
108-
await goto('/docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
108+
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
109109

110110
// Find and click the version selector button (wait for it to be visible)
111111
const versionButton = page.locator('header button').filter({ hasText: '1.6.3' })
@@ -123,7 +123,7 @@ test.describe('Version Selector', () => {
123123
})
124124

125125
test('selecting a version navigates to that version', async ({ page, goto }) => {
126-
await goto('/docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
126+
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
127127

128128
// Find and click the version selector button (wait for it to be visible)
129129
const versionButton = page.locator('header button').filter({ hasText: '1.6.3' })
@@ -132,7 +132,7 @@ test.describe('Version Selector', () => {
132132
await versionButton.click()
133133

134134
// Find a version link that's not the current version by checking the href
135-
const versionLinks = page.locator('[role="option"] a[href*="/docs/ufo/v/"]')
135+
const versionLinks = page.locator('[role="option"] a[href*="/package-docs/ufo/v/"]')
136136
const count = await versionLinks.count()
137137

138138
// Find first link that doesn't point to 1.6.3
@@ -157,7 +157,7 @@ test.describe('Version Selector', () => {
157157
})
158158

159159
test('escape key closes version dropdown', async ({ page, goto }) => {
160-
await goto('/docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
160+
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
161161

162162
// Wait for version button to be visible
163163
const versionButton = page.locator('header button').filter({ hasText: '1.6.3' })

test/e2e/interactions.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ test.describe('Search Pages', () => {
2121
await page.keyboard.press('ArrowUp')
2222

2323
// Enter navigates to the selected result
24-
// URL is /vue not /package/vue (cleaner URLs)
24+
// URL is /package/vue not /vue
2525
await page.keyboard.press('Enter')
26-
await expect(page).toHaveURL(/\/vue/)
26+
await expect(page).toHaveURL(/\/package\/vue/)
2727
})
2828

2929
test('/search?q=vue → "/" focuses the search input from results', async ({ page, goto }) => {
@@ -109,7 +109,7 @@ test.describe('Keyboard Shortcuts', () => {
109109
page,
110110
goto,
111111
}) => {
112-
await goto('/vue', { waitUntil: 'hydration' })
112+
await goto('/package/vue', { waitUntil: 'hydration' })
113113

114114
await page.keyboard.press('c')
115115

@@ -136,7 +136,7 @@ test.describe('Keyboard Shortcuts', () => {
136136
page,
137137
goto,
138138
}) => {
139-
await goto('/vue', { waitUntil: 'hydration' })
139+
await goto('/package/vue', { waitUntil: 'hydration' })
140140

141141
await page.keyboard.press('Shift+c')
142142
await expect(page).toHaveURL(/\/vue/)

test/e2e/package-manager-select.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@nuxt/test-utils/playwright'
22

33
test.describe('Package Page', () => {
44
test('/vue → package manager select dropdown works', async ({ page, goto }) => {
5-
await goto('/vue', { waitUntil: 'hydration' })
5+
await goto('/package/vue', { waitUntil: 'hydration' })
66

77
await expect(page.locator('h1')).toContainText('vue', { timeout: 15000 })
88

test/nuxt/a11y.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ describe('component accessibility audits', () => {
626626
props: {
627627
tree: mockTree,
628628
currentPath: '',
629-
baseUrl: '/code/vue',
629+
baseUrl: '/package-code/vue',
630630
},
631631
})
632632
const results = await runAxe(component)
@@ -638,7 +638,7 @@ describe('component accessibility audits', () => {
638638
props: {
639639
tree: mockTree,
640640
currentPath: 'src',
641-
baseUrl: '/code/vue',
641+
baseUrl: '/package-code/vue',
642642
},
643643
})
644644
const results = await runAxe(component)
@@ -662,7 +662,7 @@ describe('component accessibility audits', () => {
662662
props: {
663663
tree: mockTree,
664664
currentPath: '',
665-
baseUrl: '/code/vue',
665+
baseUrl: '/package-code/vue',
666666
},
667667
})
668668
const results = await runAxe(component)
@@ -674,7 +674,7 @@ describe('component accessibility audits', () => {
674674
props: {
675675
tree: mockTree,
676676
currentPath: 'src/index.ts',
677-
baseUrl: '/code/vue',
677+
baseUrl: '/package-code/vue',
678678
},
679679
})
680680
const results = await runAxe(component)
@@ -889,7 +889,7 @@ describe('component accessibility audits', () => {
889889
props: {
890890
tree: mockTree,
891891
currentPath: '',
892-
baseUrl: '/code/vue',
892+
baseUrl: '/package-code/vue',
893893
},
894894
})
895895
const results = await runAxe(component)
@@ -1766,7 +1766,7 @@ describe('component accessibility audits', () => {
17661766
currentVersion: '3.5.0',
17671767
versions: mockVersions,
17681768
distTags: mockDistTags,
1769-
urlPattern: '/vue/v/{version}',
1769+
urlPattern: '/package/vue/v/{version}',
17701770
},
17711771
})
17721772
const results = await runAxe(component)
@@ -1780,7 +1780,7 @@ describe('component accessibility audits', () => {
17801780
currentVersion: '3.4.0',
17811781
versions: mockVersions,
17821782
distTags: mockDistTags,
1783-
urlPattern: '/vue/v/{version}',
1783+
urlPattern: '/package/vue/v/{version}',
17841784
},
17851785
})
17861786
const results = await runAxe(component)

0 commit comments

Comments
 (0)