Skip to content

Commit

Permalink
Adding data attr to inlined font definition (#44008)
Browse files Browse the repository at this point in the history
Adding data attr to inlined font definition from optimizeFonts feature
  • Loading branch information
janicklas-ralph authored Dec 13, 2022
1 parent 7b84d63 commit 6d3be75
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/next/server/post-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
result = result.replace('</head>', `${fallBackLinkTag}</head>`)
} else {
const nonceStr = nonce ? ` nonce="${nonce}"` : ''
let dataAttr = ''

if (fontContent.includes('ascent-override')) {
dataAttr = ' data-size-adjust="true"'
}

result = result.replace(
'</head>',
`<style data-href="${url}"${nonceStr}>${fontContent}</style></head>`
`<style data-href="${url}"${nonceStr}${dataAttr}>${fontContent}</style></head>`
)

// Remove inert font tag
Expand Down

0 comments on commit 6d3be75

Please sign in to comment.