Fix news index date extraction with JSON-LD fallback#282
Merged
Conversation
- Add extractDateFromJSONLD() to extract dates from JSON-LD structured data - Add normalizeDateString() to handle ISO timestamps and date formats - Update date extraction to use multi-level fallback: 1. article:published_time (Open Graph) 2. name="date" (simple meta tag) 3. datePublished from JSON-LD 4. Filename extraction 5. Current date (last resort) - Fixes parliament-agenda articles showing today's date instead of 2026-02-07 - Normalizes all dates to YYYY-MM-DD format for consistency - Regenerated all 14 language news index files with correct dates Co-authored-by: pethers <[email protected]>
Copilot
AI
changed the title
[WIP] Investigate incorrect metadata for parliament agenda page
Fix news index date extraction with JSON-LD fallback
Feb 18, 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 PR fixes a critical bug where news articles without article:published_time meta tags were showing incorrect dates (defaulting to today's date instead of the actual publication date). The fix adds JSON-LD structured data as a fallback source and normalizes all dates to YYYY-MM-DD format.
Changes:
- Added
normalizeDateString()function to convert ISO timestamps to YYYY-MM-DD format - Added
extractDateFromJSONLD()function to extract dates from JSON-LD structured data - Extended the date extraction fallback chain from 2 to 5 levels
- Regenerated all 14 language index files with corrected dates
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/generate-news-indexes.js | Added date normalization and JSON-LD extraction functions, enhanced fallback chain |
| package-lock.json | Added peer dependency flags (expected npm behavior) |
| news/index_*.html (14 files) | Normalized dates from ISO timestamps to YYYY-MM-DD format, corrected article ordering |
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.
Articles without
article:published_timemeta tags were falling back to filename extraction, then defaulting to today's date.2026-02-parliament-agenda-*.html(published 2026-02-07) displayed as 2026-02-18 in news indexes.Changes
Enhanced date extraction in
generate-news-indexes.js:extractDateFromJSONLD()to parsedatePublishedfrom JSON-LD structured datanormalizeDateString()to convert ISO timestamps toYYYY-MM-DDarticle:published_time(Open Graph)name="date"(simple meta tag)datePublishedfrom JSON-LD ← newYYYY-MM-DD)Before:
After:
Impact
parliament-agenda(2026-02-07),committee-reports(2026-02-06), and similar articlesYYYY-MM-DDformat (removes ISO timestamps)💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.