Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(unhead): add tagWeight option and meta-beyond-1mb validation rule#716

Merged
harlan-zw merged 2 commits into
mainfrom
worktree-feat-custom-tag-weight
Apr 5, 2026
Merged

feat(unhead): add tagWeight option and meta-beyond-1mb validation rule#716
harlan-zw merged 2 commits into
mainfrom
worktree-feat-custom-tag-weight

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a public tagWeight option to CreateServerHeadOptions that allows users to override the default CAPO tag weight function. This enables reordering <head> tags per-request — e.g. promoting SEO meta above styles when the request comes from a bot.
  • Adds a meta-beyond-1mb validation rule to the ValidatePlugin that warns when meta tags are rendered beyond the crawler byte parsing limit (default 1MB). Social crawlers (Facebook, Twitter) only parse the first ~1MB of HTML, and large inline styles can push OG/SEO meta past this limit.
  • capoTagWeight is already exported from unhead/server, so users can easily wrap it:
import { createHead, capoTagWeight } from 'unhead/server'

createHead({
  tagWeight(tag) {
    if (isBot && tag.tag === 'meta' && tag.props.property?.startsWith('og:'))
      return 55 // just above styles (60)
    return capoTagWeight(tag)
  }
})

Closes #693

Test plan

  • tagWeight option test: custom weight function promotes meta above styles
  • meta-beyond-1mb validation rule: warns when meta rendered past configurable byte limit
  • meta-beyond-1mb does not warn when within limit
  • All 97 existing tests continue to pass
  • Type check passes

🤖 Generated with Claude Code

… rule

Allow users to customise CAPO tag weights via `CreateServerHeadOptions.tagWeight`.
This enables reordering `<head>` tags based on request context (e.g. promoting SEO
meta above styles for bot requests).

Also adds a `meta-beyond-1mb` validation rule to the validate plugin that warns
when meta tags are rendered beyond the crawler byte parsing limit (default 1MB),
which can happen when large inline styles push OG/SEO tags too far down.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@harlan-zw has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 29 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 2 minutes and 29 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 83750811-0919-42a0-9271-fb936eb41390

📥 Commits

Reviewing files that changed from the base of the PR and between 4c785c0 and b90d1be.

📒 Files selected for processing (7)
  • docs/head/1.guides/1.core-concepts/2.positions.md
  • docs/head/1.guides/plugins/validate.md
  • packages/unhead/src/plugins/validate.ts
  • packages/unhead/src/server/createHead.ts
  • packages/unhead/src/types/head.ts
  • packages/unhead/test/unit/plugins/validate.test.ts
  • packages/unhead/test/unit/server/tagPriority.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-feat-custom-tag-weight

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

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Bundle Size Gzipped
Client (Minimal) 10.6 kB 4.3 kB
Server (Minimal) 10.3 kB 4.2 kB
Vue Client (Minimal) 11.6 kB 4.8 kB
Vue Server (Minimal) 11.3 kB 4.6 kB

@harlan-zw harlan-zw merged commit c58be62 into main Apr 5, 2026
6 checks passed
@harlan-zw harlan-zw mentioned this pull request Apr 6, 2026
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.

SEO tags prioritised below style tags

1 participant