Skip to content

Commit 0740123

Browse files
fix: add required field check
1 parent 5e5a67e commit 0740123

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/google-fonts.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ function injectFonts({
2222
const deferedSpecs: string[] = []
2323
let links = ''
2424

25+
if (!Array.isArray(families)) {
26+
console.warn('Google font families is required')
27+
28+
return html
29+
}
30+
2531
if (families.length >= 0) {
2632
for (const family of families) {
2733
if (typeof family === 'string') {

src/typekit.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ function injectFonts({
1111
}: TypeKitFonts, html: string): string {
1212
let links = ''
1313

14+
if (typeof id !== 'string') {
15+
console.warn('A Typekit id is required')
16+
17+
return html
18+
}
19+
1420
if (defer)
1521
links += `<link rel="preload" href="${TypekitFontBase}${id}.css" as="style" onload="this.rel='stylesheet'">`
1622
else

0 commit comments

Comments
 (0)