Skip to content

fix(metadata): gate twitter app and player tags on card type - #2053

Merged
james-elicx merged 1 commit into
cloudflare:mainfrom
Xplod13:fix/twitter-app-card-gating
Jun 15, 2026
Merged

fix(metadata): gate twitter app and player tags on card type#2053
james-elicx merged 1 commit into
cloudflare:mainfrom
Xplod13:fix/twitter-app-card-gating

Conversation

@Xplod13

@Xplod13 Xplod13 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Gate twitter:app:* tags on card === "app" and twitter:player:* tags on card === "player", instead of emitting them whenever a twitter.app / twitter.players object exists.
  • Skip falsy twitter:app:id / twitter:app:url values (0, "").

Root Cause

The Twitter metadata renderer (shims/metadata.tsx) gated the app block on if (tw.app) and the player block on if (tw.players) — purely on object presence, not on the resolved card type. So a user who set twitter: { app: {...} } while the card defaulted to summary still got twitter:app:* tags (and the analogous problem for player cards). It also emitted twitter:app:id/twitter:app:url for falsy values because it tested !== undefined.

Next.js gates each sub-block on the resolved card (if (card === 'app'), if (card === 'player')) and uses truthy checks for app id/url. The fix mirrors that: gate app on card === "app", player on card === "player", and use truthy checks. The card is already defaulted in postProcessMetadata (summary_large_image when images are present, else summary), matching Next.js' resolve-opengraph defaulting, so the gate always compares against a resolved value.

References

Verification

  • CI=true pnpm test tests/file-based-metadata.test.ts tests/nextjs-compat/metadata.test.ts — new cases: no twitter:app:* when card isn't app; falsy app ids skipped while truthy ones emit; no twitter:player:* when card isn't player; player tags emit when card is player. Red before, green after; existing twitter card tests still pass (71 passed).
  • CI=true pnpm test — full battery green (only the pre-existing env flakes deploy.test.ts > resolveWranglerBin and oxlint-prefer-shared-utils, reproduced identically on origin/main).
  • CI=true npx vp check — clean on both changed files.

The Twitter metadata renderer emitted `twitter:app:*` tags whenever a
`twitter.app` object was present and `twitter:player:*` tags whenever
`twitter.players` was present, regardless of the resolved card type. It also
emitted `twitter:app:id`/`twitter:app:url` for falsy values (`0`, `""`).

Next.js gates these blocks on the resolved card: `if (card === 'app')` and
`if (card === 'player')`, and uses truthy checks for app id/url. Mirror that:
gate the app block on `card === 'app'`, the player block on `card === 'player'`,
and skip falsy app ids/urls. The card is already defaulted in
postProcessMetadata (summary_large_image / summary), matching Next.js.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Jun 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2053
npm i https://pkg.pr.new/vinext@2053

commit: 602de09

@james-elicx

Copy link
Copy Markdown
Member

/bigbonk review for issues

@james-elicx
james-elicx merged commit 50f435c into cloudflare:main Jun 15, 2026
44 checks passed
@ask-bonk

ask-bonk Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@james-elicx Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

@Xplod13
Xplod13 deleted the fix/twitter-app-card-gating branch June 16, 2026 17:09
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.

Metadata: twitter:app:* tags emitted regardless of card type; falsy app ids not skipped

2 participants