Preview checker: a long `og:title` or `og:description` gets no warning when the page also has a normal title and description

Aberta Para iniciantes
#458 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

@Imhamza86 já está trabalhando nisso.

Desde 4/12/2026.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
88/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
backend

Direção de pesquisa

Comece em src/lib/meta-analyzer.ts e leia as verificações existentes do tamanho do título e da descrição. Em seguida, revise os casos relacionados em tests/lib/meta-analyzer.test.ts. Adicione cobertura para valores longos de Open Graph junto com valores normais e para textos correspondentes e diferentes. O trabalho estará concluído quando os avisos e as deduções de pontuação especificados estiverem cobertos, o comportamento de fallback existente for preservado e as verificações listadas passarem.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug good first issue

analyzeMeta only checks the length of one title and one description: tags.title || tags.ogTitle and tags.description || tags.ogDescription (src/lib/meta-analyzer.ts lines 21 and 35). So when a page has a <title> and a meta description, the og:title and og:description never get measured, and those are the ones the social previews show.

I ran parseMetaTags and analyzeMeta on the current dev with a page where everything else is set:

everything normal              → score 100 (A), no issues
og:title is 116 chars          → score 100 (A), no issues
og:description is 418 chars    → score 100 (A), no issues
<title> is 116 chars           → score 95 (A), "Title is 116 chars (recommended: under 70)"

#333 made the title check fall back to og:title when there's no <title>. This is the other half: a page that has both.

What to do

  • After the current title check, also check og:title when it's set and isn't the same text as the title that was just checked. Over 70 characters gives a warning on the og:title tag, like og:title is 116 chars (recommended: under 70), and takes 5 points like the title does.
  • Do the same for og:description over 160 characters, as a warning on the og:description tag that takes 3 points like the description does.
  • When there's no <title> or no meta description, keep what happens now: the Open Graph value is the one that gets checked, once.
  • The "too short" description warning stays as it is, this one is only about values that are too long.
  • The test prefers the HTML title when both title sources are present in tests/lib/meta-analyzer.test.ts expects no warning for exactly this case, so it has to change.

Acceptance criteria

  • A 116 character og:title next to a normal <title> gets the og:title warning and scores 95
  • A 418 character og:description next to a normal description gets the og:description warning and scores 97
  • A long <title> and a long og:title with different text get one warning each
  • The same long text in <title> and og:title gets one warning, not two
  • Pages without a <title> or meta description come out exactly as before
  • A test that fails on the current code
  • npm run check, npm run test and npm run build pass

How to test
Run the new tests, then npm run dev, open /preview and check a page with a short <title> and a long og:title. The report should list the og:title warning.


Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #458 in the description.

Linguagem predominante
TypeScript
Estrelas
8
Forks
4
Merge médio
1d 21h
PRs com merge (30d)
34

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de codercops/ogcops

Todas as issues de codercops/ogcops

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.