Skip to content

Commit

Permalink
fixing the edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekbh committed Nov 17, 2020
1 parent ca590c4 commit c2e790f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/next/next-server/lib/post-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,20 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
continue
}
const fontContent = options.getFontDefinition(url)
result = result.replace(
'</head>',
`<style data-href="${url}">${fontContent}</style></head>`
)
if (!fontContent) {
/**
* In case of unreachable font definitions, fallback to default link tag.
*/
result = result.replace(
'</head>',
`<link rel="stylesheet" href="${url}"/></head>`
)
} else {
result = result.replace(
'</head>',
`<style data-href="${url}">${fontContent}</style></head>`
)
}
}
return result
}
Expand Down

0 comments on commit c2e790f

Please sign in to comment.