Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

fix(schema): cleanup meta tags and deduplicate charset/viewport - #6378

Merged
pi0 merged 3 commits into
mainfrom
fix/cleanup-head
Aug 7, 2022
Merged

fix(schema): cleanup meta tags and deduplicate charset/viewport#6378
pi0 merged 3 commits into
mainfrom
fix/cleanup-head

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/nuxt#14477, resolvesnuxt/nuxt#13758

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to 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

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroedanielroe added bug Something isn't working dx 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Aug 5, 2022
@danielroe
danielroe requested a review from pi0August 5, 2022 11:19
@danielroedanielroe self-assigned this Aug 5, 2022
@netlify

netlifyBot commented Aug 5, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commitf554de3
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/62ed42b02285350008eaf17d

Comment threadpackages/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',

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
MemberAuthor

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?

@pi0pi0Aug 5, 2022

Copy link
Copy Markdown
Member

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.

Comment threadtest/fixtures/basic/nuxt.config.ts
@danielroe
danielroe requested a review from pi0August 5, 2022 17:45
pi0
pi0 approved these changes Aug 7, 2022
@pi0
pi0 merged commit fc1d7d9 into mainAug 7, 2022
@pi0
pi0 deleted the fix/cleanup-head branch August 7, 2022 09:53
@pi0pi0 mentioned this pull request Aug 9, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't workingdx🍰 p2-nice-to-havePriority 2: nothing is broken but it's worth addressingschema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot read properties of null (reading 'getAttribute') infinite log loop nuxt3 meta tag error

2 participants

@danielroe@pi0