router icon indicating copy to clipboard operation
router copied to clipboard

Implement meta tag deduplication logic

Open juliusmarminge opened this issue 1 month ago β€’ 3 comments

Add logic to determine if meta tags should be deduplicated.

Closes #5146

Summary by CodeRabbit

  • Bug Fixes
    • Improved meta tag handling to allow multiple theme-color entries while preserving automatic deduplication for other meta attributes.

juliusmarminge avatar Oct 28 '25 19:10 juliusmarminge

Walkthrough

The change modifies the meta tag deduplication logic in HeadContent.tsx to allow multiple theme-color meta tags instead of replacing them. A new set defines which attributes should allow duplicates, with a helper function determining eligibility for deduplication.

Changes

Cohort / File(s) Summary
Meta tag deduplication logic
packages/react-router/src/HeadContent.tsx
Introduced METAS_TO_ALLOW_MULTIPLE set containing 'theme-color' and shouldDeduplicateMetaTag() helper function. Updated deduplication logic to permit multiple meta tags for attributes in this set while maintaining deduplication for other attributes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file with localized changes to an existing deduplication mechanism
  • Straightforward logic: simple set definition and conditional check
  • Well-scoped change with clear intent and minimal side effects

Suggested reviewers

  • birkskyum

Poem

🌈 A coat of many colors now adorns the head, Theme-color tags bloom where once just one spread, Light and dark hues dance side by side, Multiple shades, no longer cast aside! 🎨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check βœ… Passed The PR title "Implement meta tag deduplication logic" directly and clearly describes the main change in the pull request. The raw summary confirms that the changes introduce meta tag deduplication logic with a METAS_TO_ALLOW_MULTIPLE set and shouldDeduplicateMetaTag helper function. The title is concise, specific, and accurately conveys the primary modification to the codebase.
Linked Issues Check βœ… Passed The PR directly addresses the requirement from issue #5146, which requests the ability to include multiple meta tags with the same name (specifically theme-color with different media attributes). The implementation introduces METAS_TO_ALLOW_MULTIPLE containing 'theme-color' and implements shouldDeduplicateMetaTag logic that permits multiple meta tags for specified attributes, effectively allowing multiple theme-color tags to coexist in the document head instead of being deduplicated. This satisfies the core objective of preserving multiple theme-color meta tags with different media attributes for light/dark color schemes.
Out of Scope Changes Check βœ… Passed All changes in this PR are contained within packages/react-router/src/HeadContent.tsx and are directly related to the scope defined in issue #5146. The modifications include introducing the METAS_TO_ALLOW_MULTIPLE set, adding the shouldDeduplicateMetaTag helper, and updating the meta deduplication logic to selectively allow multiple meta tags for certain attributes. These changes are focused solely on enabling multiple theme-color meta tags and do not introduce any unrelated modifications.
✨ Finishing touches
  • [ ] πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

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.

coderabbitai[bot] avatar Oct 28 '25 19:10 coderabbitai[bot]

View your CI Pipeline Execution β†— for commit 893579accf8a362c96cf959d5cb9dba27ecae3d2

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... βœ… Succeeded 9m 1s View β†—
nx run-many --target=build --exclude=examples/*... βœ… Succeeded 56s View β†—

☁️ Nx Cloud last updated this comment at 2025-10-28 19:32:39 UTC

nx-cloud[bot] avatar Oct 28 '25 19:10 nx-cloud[bot]

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5676
@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5676
@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5676
@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5676
@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5676
@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5676
@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5676
@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5676
@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5676
@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5676
@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5676
@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5676
@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5676
@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5676
@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5676
@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5676
@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5676
@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5676
@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5676
@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5676
@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5676
@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5676
@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5676
@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5676
@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5676
@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5676
@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5676
@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5676
@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5676
@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5676
@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5676
@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5676
@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5676
@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5676
@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5676

commit: 893579a

pkg-pr-new[bot] avatar Oct 28 '25 19:10 pkg-pr-new[bot]