π Issue Type
Architecture / Code Quality / Testing
π― Objective
Refactor the HTML rendering pipeline (article.md β news/*.html) and all related static output generation (sitemap XML, sitemap HTML, RSS feed, news indexes) into well-architected bounded contexts with strict typing, comprehensive tests, and clear separation of concerns.
π Current State
The rendering/publishing pipeline involves multiple scripts with overlapping responsibilities:
HTML Rendering:
scripts/render-articles.ts β Main renderer (article.md β news/{date}-{type}-{lang}.html)
scripts/render-lib/article.ts β Article document model
scripts/render-lib/chrome.ts β HTML chrome/template wrapping
scripts/render-lib/chrome-i18n.ts β Internationalized chrome strings
scripts/render-lib/constants.ts β Shared constants
scripts/render-lib/jsonld.ts β JSON-LD structured data
scripts/render-lib/url-helpers.ts β URL construction
scripts/render-lib/article-types.ts β Article type registry
scripts/render-lib/markdown/ (7 files) β Markdown β HTML pipeline (rehype/remark plugins, Mermaid preprocessing, sanitization)
Supporting Generators:
scripts/generate-news-indexes/ β News index pages
scripts/generate-sitemap.ts + scripts/sitemap-xml/ β XML sitemap
scripts/generate-sitemap-html.ts + scripts/sitemap-html/ β Human-readable sitemap
scripts/generate-rss.ts + scripts/rss/ β RSS feed
scripts/generate-political-intelligence.ts β Political intelligence page
scripts/normalize-static-html-chrome.ts β Chrome normalization
scripts/backfill-translated-chrome.ts β Translation backfill
scripts/strip-legacy-chrome-script-tags.ts β Legacy cleanup
scripts/extract-news-metadata.ts β News metadata extraction
scripts/html-utils.ts β Shared HTML utilities
Issues:
- Render pipeline mixes concerns: Markdown parsing, HTML templating, i18n, SEO, and sanitization in
render-lib/
- Multiple independent scripts for sitemap/RSS/indexes with duplicated HTML generation patterns
chrome.ts is likely large and handles too many responsibilities (header, footer, nav, SEO meta, language switcher)
- Markdown pipeline in
render-lib/markdown/ tightly coupled to rendering rather than being a standalone transformation
- Inconsistent error handling between generators
- Limited test coverage for HTML output correctness (structure, accessibility, valid HTML5)
- No shared "static output writer" abstraction β each generator handles file I/O independently
π Desired State
Architecture (Bounded Contexts)
scripts/rendering/
βββ interfaces.ts # Shared types for all rendering
βββ markdown-to-html/ # Pure Markdown β HTML transformation
β βββ pipeline.ts # rehype/remark pipeline (compose plugins)
β βββ plugins/
β β βββ mermaid-preprocess.ts
β β βββ slug-prefixed.ts
β β βββ wrap-tables.ts
β β βββ sanitize.ts
β βββ index.ts
βββ article-chrome/ # HTML page chrome (header/footer/nav)
β βββ template.ts # Base HTML5 template
β βββ header.ts # Site header with nav
β βββ footer.ts # Site footer with sources
β βββ language-switcher.ts # hreflang + UI switcher
β βββ seo.ts # Meta tags, OG, Twitter Cards
β βββ jsonld.ts # JSON-LD structured data
β βββ index.ts
βββ i18n/ # Internationalization for chrome
β βββ strings.ts # UI string registry (14 langs)
β βββ rtl.ts # RTL layout handling
β βββ index.ts
βββ article-renderer/ # Compose markdown + chrome β full page
β βββ renderer.ts # Main article rendering
β βββ index.ts
βββ index.ts # Public API
scripts/static-outputs/
βββ interfaces.ts # Shared types for generators
βββ sitemap-xml/ # XML sitemap generation
βββ sitemap-html/ # Human-readable sitemap
βββ rss/ # RSS feed generation
βββ news-indexes/ # News index pages
βββ political-intelligence/ # Political intelligence page
βββ writer.ts # Shared file writer with validation
βββ index.ts
Code Quality
- Clear separation: Markdown transformation is independent of HTML chrome
- Each chrome component (header, footer, nav, SEO) is independently testable
- i18n strings centralized β no scattered translations
- Shared file writer handles I/O, encoding, and validation consistently
- All HTML output validated against HTML5 spec in tests
- No
any types β typed interfaces for article metadata, page context, i18n strings
Test Quality
- Each component has unit tests verifying:
- Correct HTML5 structure output
- WCAG 2.1 AA compliance (ARIA, contrast, keyboard nav)
- All 14 language outputs (including RTL for AR/HE)
- JSON-LD correctness (Schema.org NewsArticle)
- hreflang alternate links
- RSS/sitemap XML validity
- Snapshot tests for rendered HTML stability
- Integration tests for full render pipeline
- Link integrity tests for generated cross-references
π§ Implementation Approach
- Map current architecture: Document data flow through
render-articles.ts β render-lib/ β file output
- Define interfaces: Type definitions for article context, page metadata, chrome options, i18n strings
- Separate Markdown pipeline: Extract
render-lib/markdown/ into standalone bounded context
- Decompose chrome: Split
chrome.ts into focused components (header, footer, nav, SEO, jsonld)
- Centralize i18n: Single source of truth for all UI strings across 14 languages
- Unify static generators: Shared writer + validation for sitemap/RSS/indexes
- Write comprehensive tests: HTML structure, accessibility, i18n, SEO validation
- Validate: Ensure all generated HTML/XML/RSS output is identical before/after refactoring
π Key Files
| File |
Purpose |
scripts/render-articles.ts |
Main article renderer |
scripts/render-lib/ (11+ files) |
Rendering library |
scripts/render-lib/markdown/ (7 files) |
Markdown pipeline |
scripts/render-lib/aggregator/ (9 files) |
Content aggregation |
scripts/generate-news-indexes/ |
News index generation |
scripts/generate-sitemap.ts + scripts/sitemap-xml/ |
XML sitemap |
scripts/generate-sitemap-html.ts + scripts/sitemap-html/ |
HTML sitemap |
scripts/generate-rss.ts + scripts/rss/ |
RSS feed |
scripts/generate-political-intelligence.ts |
Intelligence page |
scripts/html-utils.ts |
Shared HTML utilities |
scripts/normalize-static-html-chrome.ts |
Chrome normalization |
scripts/backfill-translated-chrome.ts |
Translation backfill |
tests/render-lib.test.ts |
Existing render tests |
tests/render-lib-architecture.test.ts |
Architecture tests |
tests/generate-rss.test.ts |
RSS generation tests |
tests/generate-sitemap.test.ts |
Sitemap tests |
tests/generate-sitemap-html.test.ts |
HTML sitemap tests |
tests/generate-news-indexes.test.ts |
News index tests |
Article-Generation.md |
System documentation |
β
Acceptance Criteria
π€ Recommended Agent
code-quality-engineer β Architecture refactoring, HTML/CSS quality, bounded contexts, test coverage
π·οΈ Labels
enhancement, refactor, testing, component:content-generation, news-generation, html-css, i18n, priority-high, size-xl
π Issue Type
Architecture / Code Quality / Testing
π― Objective
Refactor the HTML rendering pipeline (
article.mdβnews/*.html) and all related static output generation (sitemap XML, sitemap HTML, RSS feed, news indexes) into well-architected bounded contexts with strict typing, comprehensive tests, and clear separation of concerns.π Current State
The rendering/publishing pipeline involves multiple scripts with overlapping responsibilities:
HTML Rendering:
scripts/render-articles.tsβ Main renderer (article.md β news/{date}-{type}-{lang}.html)scripts/render-lib/article.tsβ Article document modelscripts/render-lib/chrome.tsβ HTML chrome/template wrappingscripts/render-lib/chrome-i18n.tsβ Internationalized chrome stringsscripts/render-lib/constants.tsβ Shared constantsscripts/render-lib/jsonld.tsβ JSON-LD structured datascripts/render-lib/url-helpers.tsβ URL constructionscripts/render-lib/article-types.tsβ Article type registryscripts/render-lib/markdown/(7 files) β Markdown β HTML pipeline (rehype/remark plugins, Mermaid preprocessing, sanitization)Supporting Generators:
scripts/generate-news-indexes/β News index pagesscripts/generate-sitemap.ts+scripts/sitemap-xml/β XML sitemapscripts/generate-sitemap-html.ts+scripts/sitemap-html/β Human-readable sitemapscripts/generate-rss.ts+scripts/rss/β RSS feedscripts/generate-political-intelligence.tsβ Political intelligence pagescripts/normalize-static-html-chrome.tsβ Chrome normalizationscripts/backfill-translated-chrome.tsβ Translation backfillscripts/strip-legacy-chrome-script-tags.tsβ Legacy cleanupscripts/extract-news-metadata.tsβ News metadata extractionscripts/html-utils.tsβ Shared HTML utilitiesIssues:
render-lib/chrome.tsis likely large and handles too many responsibilities (header, footer, nav, SEO meta, language switcher)render-lib/markdown/tightly coupled to rendering rather than being a standalone transformationπ Desired State
Architecture (Bounded Contexts)
Code Quality
anytypes β typed interfaces for article metadata, page context, i18n stringsTest Quality
π§ Implementation Approach
render-articles.tsβrender-lib/β file outputrender-lib/markdown/into standalone bounded contextchrome.tsinto focused components (header, footer, nav, SEO, jsonld)π Key Files
scripts/render-articles.tsscripts/render-lib/(11+ files)scripts/render-lib/markdown/(7 files)scripts/render-lib/aggregator/(9 files)scripts/generate-news-indexes/scripts/generate-sitemap.ts+scripts/sitemap-xml/scripts/generate-sitemap-html.ts+scripts/sitemap-html/scripts/generate-rss.ts+scripts/rss/scripts/generate-political-intelligence.tsscripts/html-utils.tsscripts/normalize-static-html-chrome.tsscripts/backfill-translated-chrome.tstests/render-lib.test.tstests/render-lib-architecture.test.tstests/generate-rss.test.tstests/generate-sitemap.test.tstests/generate-sitemap-html.test.tstests/generate-news-indexes.test.tsArticle-Generation.mdβ Acceptance Criteria
anytypes in rendering codenpm test)Article-Generation.mdupdated to reflect new rendering architectureπ€ Recommended Agent
code-quality-engineerβ Architecture refactoring, HTML/CSS quality, bounded contexts, test coverageπ·οΈ Labels
enhancement,refactor,testing,component:content-generation,news-generation,html-css,i18n,priority-high,size-xl