-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Add default utf-8 charset. #270
Conversation
@@ -33,7 +33,7 @@ export async function render (url, ctx = {}, { | |||
return (staticMarkup ? renderToStaticMarkup : renderToString)(app) | |||
}) | |||
|
|||
const head = Head.rewind() || [] | |||
const head = Head.rewind() || defaultHead() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still want to use the default head tag(s) even if the page does not have a <Head>
.
Unfortunately it has to be a little bit more subtle: we set a default charset unless the user explicitly passes a The reason for this is that So, instead of defaultHead, your code should have a |
Also: in this day and age, having a default of utf-8 should not come as a surprise to anyone. That said, it might be prudent to do something like: console.info('Using default `<meta charSet="utf-8">`. Learn more: https://github.com/zeit/next.js/wiki/utf-8-charset') |
during dev, of course |
@rauchg Thanks for the feedback!
I believe I'm handling this requirement already. The default is appended to the children of The The scenarios I've tried to cover are: 1.) A simple page component such as <Head>
<title>My title</title>
</Head>
<Head>
<title>My title</title>
<meta charSet="utf-2016" />
</Head> I attempted to express that with the tests I added, but perhaps I could improve them. (Suggestions welcome) If this approach does not meet exceptions, could you please elaborate on the |
Sorry. File my comment under "read first 5 lines of the diff and jumped to conclusions". Amazing PR. Will merge from again. A++++++++!+!== |
Thanks! |
Stats from current PRDefault Server ModeGeneral
Client Bundles (main, webpack, commons)
Client Bundles (main, webpack, commons) Modern
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
Serverless ModeGeneral
Client Bundles (main, webpack, commons)
Client Bundles (main, webpack, commons) Modern
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles
Commit: e9b2e25 |
Closes #237.
Sets UTF-8 as the default charset for pages without a
<Head>
or with a<Head>
but no<meta charSet>
.If
<Head>
has a<meta charSet>
tag, that value will override the default.Thanks for next! 😄