-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforcing routing priority during production builds (#3407)
* WIP: have a few test failures to track down * WIP: still a few failures to fix * WIP: fixes the issue of dynamic routes stepping on static routes * Resolve route priority before building routes for `getStaticPaths()` * chore: adding comments explaining why this filter is needed * chore: adding changeset * got too fancy with the test suite, these routes weren't valid * simplifying the test cases * TEMP: is this test breaking my CI run? * Revert "TEMP: is this test breaking my CI run?" This reverts commit 291af2a. * slots-preact didn't list @astrojs/preact as a dep * reverting copy/paste error
- Loading branch information
Tony Sullivan
committed
May 20, 2022
1 parent
60d7164
commit 6373508
Showing
13 changed files
with
406 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Adds a check during build to make sure routing priority is always enforced in the final dist output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/astro/test/fixtures/routing-priority/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { defineConfig } from 'astro/config'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@test/routing-priority", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/astro/test/fixtures/routing-priority/src/pages/[lang]/[...catchall].astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
export async function getStaticPaths() { | ||
return [ | ||
{ params: { lang: 'de', catchall: '1/2' } }, | ||
{ params: { lang: 'en', catchall: '1/2' } } | ||
] | ||
} | ||
--- | ||
|
||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Routing</title> | ||
</head> | ||
|
||
<body> | ||
<h1>[lang]/[...catchall].astro</h1> | ||
<p>{Astro.params.lang} | {Astro.params.catchall}</p> | ||
</body> | ||
|
||
</html> |
23 changes: 23 additions & 0 deletions
23
packages/astro/test/fixtures/routing-priority/src/pages/[lang]/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
export async function getStaticPaths() { | ||
return [ | ||
{ params: { lang: 'de' } }, // always shadowed by /de/index.astro | ||
{ params: { lang: 'en' } } | ||
]; | ||
} | ||
--- | ||
|
||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Routing</title> | ||
</head> | ||
|
||
<body> | ||
<h1>[lang]/index.astro</h1> | ||
<p>{Astro.params.lang}</p> | ||
</body> | ||
|
||
</html> |
12 changes: 12 additions & 0 deletions
12
packages/astro/test/fixtures/routing-priority/src/pages/de/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
--- | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Routing</title> | ||
</head> | ||
<body> | ||
<h1>de/index.astro</h1> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
packages/astro/test/fixtures/routing-priority/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
--- | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Routing</title> | ||
</head> | ||
<body> | ||
<h1>index.astro</h1> | ||
</body> | ||
</html> |
24 changes: 24 additions & 0 deletions
24
packages/astro/test/fixtures/routing-priority/src/pages/posts/[...slug].astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
export async function getStaticPaths() { | ||
return [ | ||
{ | ||
params: { slug: "1/2" }, | ||
} | ||
] | ||
} | ||
--- | ||
|
||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Routing</title> | ||
</head> | ||
|
||
<body> | ||
<h1>posts/[...slug].astro</h1> | ||
<p>{Astro.params.slug}</p> | ||
</body> | ||
|
||
</html> |
23 changes: 23 additions & 0 deletions
23
packages/astro/test/fixtures/routing-priority/src/pages/posts/[pid].astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
export async function getStaticPaths() { | ||
return [ | ||
{ params: { pid: 'post-1' } }, | ||
{ params: { pid: 'post-2' } } | ||
] | ||
} | ||
--- | ||
|
||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Routing</title> | ||
</head> | ||
|
||
<body> | ||
<h1>posts/[pid].astro</h1> | ||
<p>{Astro.params.pid}</p> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.