Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: use a key prop to override Meta tags #39

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DaniGuardiola
Copy link

@DaniGuardiola DaniGuardiola commented Nov 21, 2023

What this changes

  • <Meta> tags are not replaced by default.
  • <Meta> tags are considered to be the same and overridden if the key (string) prop matches.

That's it. <Title> is still always replaced.

Why

  • No complicated/surprising heuristics.
  • Easier to maintain.
  • Explicit and opt-in.
  • Less surface for bugs.

Why not userland

  • Server-side is a pain to get right, yet critical, especially for open-graph and other metadata (crawlers won't always execute JS).
  • Duplicated logic - this library already needs to override <Title>, so userland de-duplication of meta tags would essentially add the same logic.
  • I personally would expect my framework to handle this.
  • Other popular frameworks like Next.js do exactly this. Fun fact, I only found out about this after writing this proposal. Other examples: Remix, Nuxt.

Status

Work in progress, need to figure out the tests but the basic implementation is done. Also, I think the key prop will currently be set as an attribute, so probably need to exclude it before rendering. Couldn't test yet because of local env issues.

Open questions

  • Is key an appropriate/descriptive prop name for this?
  • Should this behavior apply to other tags? (I think probably not)

Related

#34 #40

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.

1 participant