-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(styles): do not remove external styles of font providers (#217)
* fix: keep font provides styles * test: add tests * chore: typo
- Loading branch information
Showing
5 changed files
with
40 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 |
---|---|---|
|
@@ -2,4 +2,5 @@ $bg-color: #0cf; | |
|
||
body { | ||
background: $bg-color; | ||
font-family: Langar; | ||
} |
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 |
---|---|---|
@@ -1,3 +1,25 @@ | ||
import consola from 'consola' | ||
|
||
export const logger = consola.withScope('@nuxtjs/amp') | ||
|
||
export const VALID_FONT_PROVIDERS = [ | ||
'https://cloud.typography.com', | ||
'https://fast.fonts.net', | ||
'https://fonts.googleapis.com', | ||
'https://use.typekit.net', | ||
'https://maxcdn.bootstrapcdn.com', | ||
'https://use.fontawesome.com' | ||
] | ||
|
||
/** | ||
* Remove external stylesheet links from input head HTML and leave | ||
* valid font ptovider styles | ||
*/ | ||
export function removeExternalStyles (head) { | ||
return head.replace(/<link[^>]*rel="stylesheet"[^>]*>/gi, (v) => { | ||
if (VALID_FONT_PROVIDERS.some(domain => v.includes(domain))) { | ||
return v | ||
} | ||
return '' | ||
}) | ||
} |
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