-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(i18n): parse params and props correctly with fallback (#12709)
Co-authored-by: Emanuele Stoppa <[email protected]>
- Loading branch information
1 parent
358eae8
commit e3bfd93
Showing
5 changed files
with
104 additions
and
10 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 | ||
--- | ||
|
||
Fixes a bug where Astro couldn't correctly parse `params` and `props` when receiving i18n fallback URLs |
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
16 changes: 13 additions & 3 deletions
16
packages/astro/test/fixtures/i18n-routing-fallback/src/pages/blog/[id].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 |
---|---|---|
@@ -1,18 +1,28 @@ | ||
--- | ||
// for SSR | ||
const blogs = { | ||
1: { content: "Hello world" }, | ||
2: { content: "Eat Something" }, | ||
3: { content: "How are you?" }, | ||
} | ||
const id = Astro.params?.id; | ||
const ssrContent = id && blogs[id]?.content; | ||
// for SSG | ||
export function getStaticPaths() { | ||
return [ | ||
{params: {id: '1'}, props: { content: "Hello world" }}, | ||
{params: {id: '2'}, props: { content: "Eat Something" }}, | ||
{params: {id: '3'}, props: { content: "How are you?" }}, | ||
]; | ||
] | ||
} | ||
const { content } = Astro.props; | ||
const { content } = Astro.props | ||
--- | ||
<html> | ||
<head> | ||
<title>Astro</title> | ||
</head> | ||
<body> | ||
{content} | ||
{content || ssrContent} | ||
</body> | ||
</html> |
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