-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `base`setting, improve `preload` logic and UX Fixes #80
- Loading branch information
1 parent
33b64c8
commit 01e9c0b
Showing
7 changed files
with
146 additions
and
92 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
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 @@ | ||
{{/* | ||
GetFormat | ||
Retrieves the font format of a given resource | ||
|
||
@author @regisphilibert | ||
|
||
@context Resource (.) | ||
|
||
@access private | ||
|
||
@returns String | ||
|
||
*/}} | ||
{{ $SubType := "woff2" }} | ||
{{/* It appears CloudFlare produces an empty string when calling .MediaType.SubType on a woff2... | ||
As this is by far the best font format these days in terms of support and optimization, | ||
making it default to ensure it is not botched by cloudflare is "ok". | ||
*/}} | ||
{{ with .MediaType.SubType }} | ||
{{ $SubType = . }} | ||
{{ end }} | ||
{{ $MainType := .MediaType.MainType }} | ||
|
||
{{ return printf "%s/%s" $MainType $SubType }} |
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,38 @@ | ||
{{/* | ||
SanitizeProperties | ||
Eliminate any property which is not a font property to be used in @font-face declaration. | ||
Also clean the key (font-display > display) | ||
|
||
@author @regisphilibert | ||
|
||
@context Map (.) | ||
|
||
@access private | ||
|
||
@returns Map | ||
|
||
*/}} | ||
{{ $s := newScratch }} | ||
{{ $s.Set "data" dict }} | ||
|
||
{{ $property_keys := slice | ||
"family" | ||
"weight" | ||
"style" | ||
"display" | ||
"variant" | ||
"feature-settings" | ||
"variation-settings" | ||
"stretch" | ||
}} | ||
{{ range $key := $property_keys }} | ||
{{ with index $ $key }} | ||
{{ $s.SetInMap "data" $key . }} | ||
{{ else }} | ||
{{ with index $ (printf "font-" $key) }} | ||
{{ $s.SetInMap "data" $key . }} | ||
{{ end }} | ||
{{ end }} | ||
{{ end }} | ||
|
||
{{ return $s.Get "data" }} |