Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding data attr to inlined font definition #44008

Merged
merged 1 commit into from Dec 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/next/server/post-process.ts
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