-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Astro.url conform to build.format during the build (#4352)
* Make Astro.url conform to build.format during the build * Adding a changeset * Better implementation * fix some stuff that tests failed on * Add docs * Change to minor * account for empty path
- Loading branch information
Showing
8 changed files
with
108 additions
and
3 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': minor | ||
--- | ||
|
||
Make Astro.url match the build.format configuration during the build |
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,8 @@ | ||
{ | ||
"name": "@test/page-format", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/astro/test/fixtures/page-format/src/pages/nested/page.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,4 @@ | ||
--- | ||
const another = new URL('./another/', Astro.url); | ||
--- | ||
<a id="another" href={another.pathname}></a> |
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,52 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('build.format', () => { | ||
describe('directory', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/page-format/', | ||
}); | ||
}); | ||
|
||
describe('Build', () => { | ||
before(async () => { | ||
await fixture.build(); | ||
}); | ||
|
||
it('relative urls created point to sibling folders', async () => { | ||
let html = await fixture.readFile('/nested/page/index.html'); | ||
let $ = cheerio.load(html); | ||
expect($('#another').attr('href')).to.equal('/nested/page/another/'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('file', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/page-format/', | ||
build: { | ||
format: 'file', | ||
}, | ||
}); | ||
}); | ||
|
||
describe('Build', () => { | ||
before(async () => { | ||
await fixture.build(); | ||
}); | ||
|
||
it('relative urls created point to sibling folders', async () => { | ||
let html = await fixture.readFile('/nested/page.html'); | ||
let $ = cheerio.load(html); | ||
expect($('#another').attr('href')).to.equal('/nested/another/'); | ||
}); | ||
}); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.