Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include CSS when child component uses Astro.glob on page (#4156)
* Include CSS when child component uses Astro.glob on page * windows compat * Make work on windows * Remove unnecessary concat
- Loading branch information
Showing
12 changed files
with
131 additions
and
53 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 | ||
--- | ||
|
||
Add CSS to page when child component uses Astro.glob |
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 was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
packages/astro/test/fixtures/glob-pages-css/src/components/Footer.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 @@ | ||
--- | ||
// The side-effect of this happening is needed for the test. | ||
await Astro.glob("../pages/**/*.astro"); | ||
--- | ||
<style> | ||
.box { | ||
height: 50px; | ||
width: 100%; | ||
background: yellow; | ||
} | ||
</style> | ||
<div class="box"></div> |
6 changes: 6 additions & 0 deletions
6
packages/astro/test/fixtures/glob-pages-css/src/components/Navbar.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,6 @@ | ||
--- | ||
// The side-effect of this happening is needed for the test. | ||
const pages = await Astro.glob("../pages/**/*.astro"); | ||
--- | ||
|
||
<div>navbar</div> |
14 changes: 14 additions & 0 deletions
14
packages/astro/test/fixtures/glob-pages-css/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,14 @@ | ||
--- | ||
import Footer from '../components/Footer.astro'; | ||
import Navbar from '../components/Navbar.astro'; | ||
--- | ||
<html> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
<Navbar /> | ||
<h1>Testing</h1> | ||
<Footer /> | ||
</body> | ||
</html> |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/glob-pages-css/src/pages/two.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,8 @@ | ||
<html> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
<h1>Testing</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,22 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Astro.glob on pages/ directory', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/glob-pages-css/', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('It includes styles from child components', async () => { | ||
let html = await fixture.readFile('/index.html'); | ||
let $ = cheerio.load(html); | ||
|
||
expect($('link[rel=stylesheet]')).to.have.a.lengthOf(1); | ||
|
||
}); | ||
}); |