fix(news): calculate word count from HTML when JSON-LD wordCount is missing#491
Merged
fix(news): calculate word count from HTML when JSON-LD wordCount is missing#491
Conversation
…issing Co-authored-by: pethers <[email protected]>
Copilot
AI
changed the title
[WIP] Fix wordCount: 0 bug in news articles metadata
fix(news): calculate word count from HTML when JSON-LD wordCount is missing
Feb 24, 2026
Contributor
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a critical metadata bug where 225 out of 668 news articles (34%) incorrectly reported wordCount: 0 in data/news-articles.json. The root cause was that agentic-workflow-generated articles lacked the wordCount field in their Schema.org JSON-LD metadata blocks, causing the metadata extraction script to default to 0.
Changes:
- Adds fallback word count calculation to
extract-news-metadata.tswhen JSON-LD wordCount is missing or zero - Regenerates
data/news-articles.jsonwith accurate word counts for all 654 articles
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/extract-news-metadata.ts | Implements fallback word counting by stripping HTML tags and counting whitespace-delimited tokens when articleData.wordCount is falsy |
| data/news-articles.json | Regenerated metadata file with corrected word counts (537-3647 words range), updated article count (626→654), and updated unique slug count (54→56) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
225 of 668 articles in
data/news-articles.jsonreportedwordCount: 0becauseextract-news-metadata.tsdefaulted to0when the Schema.org JSON-LD block omitted the field — which is always the case for agentic-workflow-generated articles.Changes
scripts/extract-news-metadata.ts: WhenarticleData.wordCountis falsy, fall back to computing word count directly from the HTML source — strip tags, split on whitespace, count tokens. Same approach used ingenerate-news-enhanced.ts.data/news-articles.json: Regenerated — all 654 articles now have accurate word counts (e.g.2239for2026-02-24-committee-reports-en.html).Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.