-
-
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.
Fixes index page with build.format=file (#5123)
* Fixes index page with build.format=file * Adding a changeset
- Loading branch information
Showing
8 changed files
with
93 additions
and
30 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 index page with build.format=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
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,24 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('build.format=file with dynamic routes', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/dynamic-route-build-file', | ||
build: { | ||
format: 'file' | ||
} | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Outputs a slug of undefined as the index.html', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
expect($('h1').text()).to.equal('Astro Store'); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/astro/test/fixtures/dynamic-route-build-file/index.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,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Astro Store</title> | ||
</head> | ||
<body> | ||
<h1>Astro Store</h1> | ||
<p>Welcome to the Astro store!</p> | ||
</body> | ||
</html> |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/dynamic-route-build-file/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/dynamic-route-build-file", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/astro/test/fixtures/dynamic-route-build-file/src/pages/[...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,38 @@ | ||
--- | ||
export async function getStaticPaths() { | ||
const pages = [ | ||
{ | ||
slug: undefined, | ||
title: "Astro Store", | ||
text: "Welcome to the Astro store!", | ||
}, | ||
{ | ||
slug: "products", | ||
title: "Astro products", | ||
text: "We have lots of products for you", | ||
}, | ||
{ | ||
slug: "products/astro-handbook", | ||
title: "The ultimative Astro handbook", | ||
text: "If you want to learn Astro, you must read this book.", | ||
}, | ||
]; | ||
return pages.map(({ slug, title, text }) => { | ||
return { | ||
params: { slug }, | ||
props: { title, text }, | ||
}; | ||
}); | ||
} | ||
const { title, text } = Astro.props; | ||
--- | ||
<html> | ||
<head> | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
<h1>{title}</h1> | ||
<p>{text}</p> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.