-
-
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.
Merge branch 'main' into feat/upgrade-sharp
- Loading branch information
Showing
52 changed files
with
450 additions
and
116 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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,42 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Custom 404.html', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/custom-404-html/', | ||
site: 'http://example.com', | ||
}); | ||
}); | ||
|
||
describe('dev', () => { | ||
let devServer; | ||
let $; | ||
|
||
before(async () => { | ||
devServer = await fixture.startDevServer(); | ||
}); | ||
|
||
after(async () => { | ||
await devServer.stop(); | ||
}); | ||
|
||
it('renders /', async () => { | ||
const html = await fixture.fetch('/').then((res) => res.text()); | ||
$ = cheerio.load(html); | ||
|
||
expect($('h1').text()).to.equal('Home'); | ||
}); | ||
|
||
it('renders 404 for /a', async () => { | ||
const html = await fixture.fetch('/a').then((res) => res.text()); | ||
$ = cheerio.load(html); | ||
|
||
expect($('h1').text()).to.equal('Page not found'); | ||
expect($('p').text()).to.equal('This 404 is a static HTML file.'); | ||
}); | ||
}); | ||
}); |
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,42 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Custom 404 with injectRoute', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/custom-404-injected/', | ||
site: 'http://example.com', | ||
}); | ||
}); | ||
|
||
describe('dev', () => { | ||
let devServer; | ||
let $; | ||
|
||
before(async () => { | ||
devServer = await fixture.startDevServer(); | ||
}); | ||
|
||
after(async () => { | ||
await devServer.stop(); | ||
}); | ||
|
||
it('renders /', async () => { | ||
const html = await fixture.fetch('/').then((res) => res.text()); | ||
$ = cheerio.load(html); | ||
|
||
expect($('h1').text()).to.equal('Home'); | ||
}); | ||
|
||
it('renders 404 for /a', async () => { | ||
const html = await fixture.fetch('/a').then((res) => res.text()); | ||
$ = cheerio.load(html); | ||
|
||
expect($('h1').text()).to.equal('Page not found'); | ||
expect($('p').text()).to.equal('/a'); | ||
}); | ||
}); | ||
}); |
4 changes: 4 additions & 0 deletions
4
packages/astro/test/fixtures/custom-404-html/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/custom-404-html", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/custom-404-html/src/pages/404.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,9 @@ | ||
<html lang="en"> | ||
<head> | ||
<title>Not Found - Custom 404</title> | ||
</head> | ||
<body> | ||
<h1>Page not found</h1> | ||
<p>This 404 is a static HTML file.</p> | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/custom-404-html/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> |
18 changes: 18 additions & 0 deletions
18
packages/astro/test/fixtures/custom-404-injected/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: 'src/404.astro', | ||
}); | ||
}, | ||
}, | ||
}, | ||
], | ||
}); |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/custom-404-injected/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,8 @@ | ||
{ | ||
"name": "@test/custom-404-injected", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/astro/test/fixtures/custom-404-injected/src/404.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,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> |
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/custom-404-injected/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
Oops, something went wrong.