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 個 reaction 已指派 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 小時
30 天內合併 PR
34

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

codercops/ogcops 的其他 Issue

查看 codercops/ogcops 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。