Skip to content

fix: respect user-provided twitter:card in InferSeoMetaPlugin - #681

Merged
harlan-zw merged 1 commit into
mainfrom
fix/555-twitter-card-override
Mar 10, 2026
Merged

harlan-zw merged 1 commit into
mainfrom
fix/555-twitter-card-override

Conversation

@harlan-zw

@harlan-zw harlan-zw commented Mar 10, 2026 •

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Resolves #555

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

The InferSeoMetaPlugin used || to fall back to 'summary_large_image' for twitterCard, which meant passing twitterCard: false to disable the output was ignored. Wrapped the twitter:card meta push in if (options.twitterCard !== false) so users can opt out entirely. The existing tagPriority: 'low' mechanism already handles runtime overrides via useSeoMeta/useHead.

Summary by CodeRabbit

  • Improvements

    • Twitter card meta tag handling is now configurable—users can disable it or customize the card type through settings
    • Existing configurations remain unaffected
  • Tests

    • Added comprehensive test coverage for Twitter card customization and disable scenarios

Make twitter:card push conditional so that `twitterCard: false` option
properly suppresses output. User-provided values already take precedence
via `tagPriority: 'low'` on the plugin entry. Adds regression tests for
both override scenarios.

Closes #555
@coderabbitai

coderabbitai Bot commented Mar 10, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91c414a4-4d5f-428f-a1e7-c4d4bb96fcd5

📥 Commits

Reviewing files that changed from the base of the PR and between 4838b84 and 283bf0a.

📒 Files selected for processing (2)
  • packages/unhead/src/plugins/inferSeoMetaPlugin.ts
  • packages/unhead/test/unit/plugins/infer-seo-meta.test.ts

📝 Walkthrough

Walkthrough

The PR adds conditional logic to the InferSeoMetaPlugin to allow users to override or disable the Twitter card meta tag, rather than unconditionally applying the default 'summary_large_image' value. Includes tests validating override and disable scenarios.

Changes

Cohort / File(s) Summary
Twitter Card Conditional Logic
packages/unhead/src/plugins/inferSeoMetaPlugin.ts
Adds a guard to conditionally push the twitter:card meta tag: if options.twitterCard is not strictly false, it includes the meta tag with either the provided value or default 'summary_large_image'. Removes unconditional addition from the main block.
Test Coverage
packages/unhead/test/unit/plugins/infer-seo-meta.test.ts
Adds three new test cases validating override behavior: useSeoMeta with twitterCard override, useHead with direct meta tag override, and InferSeoMetaPlugin with twitterCard disabled (false).

Poem

🐰 A twitter card could never bend,
But now it bends and bends again!
With false to hide or custom prose,
Override flows where once it froze. ✨

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: making the plugin respect user-provided twitter:card values instead of always using the default.
Description check ✅ Passed The description is complete with linked issue reference, change type selected, and detailed explanation of the problem and solution.
Linked Issues check ✅ Passed The changes directly address issue #555 by implementing conditional twitter:card output, allowing user overrides and disabling when twitterCard: false.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing twitter:card handling in InferSeoMetaPlugin and adding corresponding test coverage, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/555-twitter-card-override

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Bundle Size Gzipped
Client (Minimal) 10.5 kB 4.3 kB
Server (Minimal) 10.2 kB 4.2 kB
Vue Client (Minimal) 11.4 kB 4.7 kB
Vue Server (Minimal) 11.1 kB 4.6 kB

@harlan-zw
harlan-zw merged commit 77ace21 into main Mar 10, 2026
5 checks passed
@harlan-zw harlan-zw mentioned this pull request Apr 4, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 19, 2026
1 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not override twitter:card using useServerSeoMeta

1 participant