-
-
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.
Ensure that maybeRenderHead runs last (#3821)
* Ensure that maybeRenderHead runs last * Adds a changeset * Make work with MDX
- Loading branch information
Showing
5 changed files
with
67 additions
and
8 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 for putting the <head> into its own component |
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,23 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Head in its own component', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/astro-head/', | ||
site: 'https://mysite.dev/', | ||
base: '/blog', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Styles are appended to the head and not the body', async () => { | ||
let html = await fixture.readFile('/head-own-component/index.html'); | ||
let $ = cheerio.load(html); | ||
expect($('link[rel=stylesheet]')).to.have.a.lengthOf(1, 'one stylesheet overall'); | ||
expect($('head link[rel=stylesheet]')).to.have.a.lengthOf(1, 'stylesheet is in the head'); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/astro-head/src/components/Head.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 @@ | ||
--- | ||
// Head.astro | ||
const { title } = Astro.props; | ||
--- | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="icon" type="image/x-icon" href="/favicon.ico" /> | ||
<title>{title}</title> | ||
</head> |
16 changes: 16 additions & 0 deletions
16
packages/astro/test/fixtures/astro-head/src/pages/head-own-component.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,16 @@ | ||
--- | ||
// Layout.astro | ||
import Head from "../components/Head.astro"; | ||
--- | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<Head title="title"/> | ||
<body> | ||
<h1>Title Here</h1> | ||
<style> | ||
body { | ||
background: green; | ||
} | ||
</style> | ||
</body> |