-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix injected route edge case (#7399)
* fix(#7397): update astro page entryname logic * chore: add changeset * fix: update printed log for injected routes * fix: ensure /index is included * test: add custom-404-pkg test * chore: cleanup
- Loading branch information
1 parent
556fd69
commit d2020c2
Showing
10 changed files
with
127 additions
and
21 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 | ||
--- | ||
|
||
Fix edge case where injected routes would cause builds to fail in a PNPM workspace |
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
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,22 @@ | ||
import { expect } from 'chai'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Custom 404 with injectRoute from dependency', () => { | ||
describe('build', () => { | ||
/** @type {import('./test-utils.js').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/custom-404-injected-from-dep/', | ||
site: 'http://example.com', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Build succeeds', async () => { | ||
const html = await fixture.readFile('/404.html'); | ||
expect(html).to.contain('<!DOCTYPE html>'); | ||
}); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/astro/test/fixtures/custom-404-injected-from-dep/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,18 @@ | ||
import { defineConfig } from 'astro/config'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [ | ||
{ | ||
name: '404-integration', | ||
hooks: { | ||
'astro:config:setup': ({ injectRoute }) => { | ||
injectRoute({ | ||
pattern: '404', | ||
entryPoint: '@test/custom-404-pkg/404.astro', | ||
}); | ||
}, | ||
}, | ||
}, | ||
], | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/custom-404-injected-from-dep/package.json
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,9 @@ | ||
{ | ||
"name": "@test/custom-404-injected-from-dep", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@test/custom-404-pkg": "workspace:*" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/custom-404-injected-from-dep/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,11 @@ | ||
--- | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<title>Custom 404</title> | ||
</head> | ||
<body> | ||
<h1>Home</h1> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
const canonicalURL = new URL(Astro.url.pathname, Astro.site); | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<title>Not Found - Custom 404</title> | ||
</head> | ||
<body> | ||
<h1>Page not found</h1> | ||
<p>{canonicalURL.pathname}</p> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@test/custom-404-pkg", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.