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

Đang mở Phù hợp với người mới
#458 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@Imhamza86 đang làm issue này rồi.

Từ ngày 4/12/2026.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại src/lib/meta-analyzer.ts và đọc các bước kiểm tra độ dài tiêu đề và mô tả hiện có, sau đó xem lại các trường hợp liên quan trong tests/lib/meta-analyzer.test.ts. Bổ sung kiểm thử cho các giá trị Open Graph dài bên cạnh các giá trị bình thường, cũng như cho văn bản khớp nhau và khác nhau. Hoàn thành khi các cảnh báo và mức trừ điểm được chỉ định đã được kiểm thử, hành vi fallback hiện có được giữ nguyên và các bước kiểm tra được liệt kê đều đạt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
8
Fork
4
Merge trung bình
1 ngày 21 giờ
Pull request đã merge (30 ngày)
34

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codercops/ogcops

Tất cả issue của codercops/ogcops

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.