-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(schema): cleanup meta tags and deduplicate charset/viewport #6378
Conversation
β Deploy Preview for nuxt3-docs canceled.
|
packages/schema/src/config/_app.ts
Outdated
viewport: 'width=device-width, initial-scale=1', | ||
const resolved = defu(val, get('meta'), { | ||
charset: val?.meta?.find(m => m.charset)?.charset ?? 'utf-8', | ||
viewport: val?.meta?.find(m => m.name === 'viewport')?.content ?? 'width=device-width, initial-scale=1', |
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.
This logic could be simpler if we resolver after applying defu to conditionally set default viewport/charset.
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.
I guess I want to distinguish between which is source of truth. So if head.charset
is resolved to utf-8
- was that because user set it or because that was the default value?
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.
Hmmm, we can add 3rd arg to defu too for real defaults. Not sure which syntax is more readable. One liner looks little bit unreadable. But we also have a find to filter below. It could be used to handle both filter and defaults for each.
π Linked issue
resolves nuxt/nuxt#14477, resolves nuxt/nuxt#13758
β Type of change
π Description
This sanitises user input for meta config, including preventing duplicate viewport + charsets (via meta and also top-level setting). It also removes a bit of code that was previously added for Bridge support, which didn't have access to schema.
π Checklist