-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(fonts): take build config into account #13784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
27cc29f
fix(fonts): take build config into account
florian-lefebvre 00102d4
fix: test
florian-lefebvre 09ad2eb
feat: refactor fixture test
florian-lefebvre 00d18ce
feat: better abstraction
florian-lefebvre bdf354e
feat: work on unit tests
florian-lefebvre ab5b966
feat: fixture test
florian-lefebvre 3133ad7
chore: changeset
florian-lefebvre aa4db65
chore: update comment
florian-lefebvre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 the experimental fonts API to correctly take `config.base`, `config.build.assets` and `config.build.assetsPrefix` into account |
This file contains hidden or 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 hidden or 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
14 changes: 10 additions & 4 deletions
14
packages/astro/src/assets/fonts/implementations/url-proxy.ts
This file contains hidden or 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
27 changes: 27 additions & 0 deletions
27
packages/astro/src/assets/fonts/implementations/url-resolver.ts
This file contains hidden or 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,27 @@ | ||
| import type { UrlResolver } from '../definitions.js'; | ||
| import { fileExtension, joinPaths, prependForwardSlash } from '../../../core/path.js'; | ||
| import type { AssetsPrefix } from '../../../types/public/index.js'; | ||
| import { getAssetsPrefix } from '../../utils/getAssetsPrefix.js'; | ||
|
|
||
| export function createDevUrlResolver({ base }: { base: string }): UrlResolver { | ||
| return { | ||
| resolve(hash) { | ||
| return prependForwardSlash(joinPaths(base, hash)); | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| export function createBuildUrlResolver({ | ||
| base, | ||
| assetsPrefix, | ||
| }: { base: string; assetsPrefix: AssetsPrefix }): UrlResolver { | ||
| return { | ||
| resolve(hash) { | ||
| const prefix = assetsPrefix ? getAssetsPrefix(fileExtension(hash), assetsPrefix) : undefined; | ||
| if (prefix) { | ||
| return joinPaths(prefix, base, hash); | ||
| } | ||
| return prependForwardSlash(joinPaths(base, hash)); | ||
| }, | ||
| }; | ||
| } |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we remove the trailing slash anymore? Also, the comment must be updated. Line 82 still talks about trailing slash
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the comment thanks! We don't need to care about the trailing slash here anymore because this is handled by each
UrlResolver(which usejoinPaths()under the hood)