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

オープン 初心者向け
#458 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@Imhamza86 がすでに取り組んでいます。

2026年12月4日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend

調査の方向性

src/lib/meta-analyzer.tsから始めて、既存のタイトルと説明文の長さチェックを読み、その後、関連するケースをtests/lib/meta-analyzer.test.tsで確認してください。通常の値と併せて長いOpen Graph値を扱うケースと、テキストが一致する場合と異なる場合のケースを追加してください。指定された警告とスコアの減点が網羅され、既存のフォールバック動作が維持され、記載されたチェックが通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
8
フォーク
4
平均マージ
1日 21時間
マージ済み PR(30日)
34

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codercops/ogcops のほかの issue

codercops/ogcops の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。