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

Offen Anfängerfreundlich
#458 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@Imhamza86 arbeitet bereits daran.

Seit 04.12.2026.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
88/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
backend

Rechercherichtung

Beginne in src/lib/meta-analyzer.ts und lies die bestehenden Prüfungen der Titel- und Beschreibungslänge. Sieh dir anschließend die zugehörigen Fälle in tests/lib/meta-analyzer.test.ts an. Ergänze Tests für lange Open-Graph-Werte neben normalen Werten sowie für übereinstimmende und unterschiedliche Texte. Als erledigt gilt die Aufgabe, wenn die angegebenen Warnungen und Punktabzüge abgedeckt sind, das bestehende Fallback-Verhalten erhalten bleibt und die aufgeführten Prüfungen bestehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
TypeScript
Sterne
8
Forks
4
Ø Merge
1 T. 21 Std.
Gemergte PRs (30 T.)
34

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus codercops/ogcops

Alle Issues in codercops/ogcops

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.