From ff49f1616d61a3601519f5132adb2db6572d7c4b Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 6 May 2026 10:56:24 +0000
Subject: [PATCH 1/5] Initial plan
From 9e691b6f8b155b51903db0e4917ac28023fd18b8 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 6 May 2026 11:10:01 +0000
Subject: [PATCH 2/5] feat: decompose chrome.ts into focused sub-modules with
comprehensive tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Extract chrome/types.ts (interfaces: ChromeOptions, SiteChrome, BreadcrumbItem)
- Extract chrome/helpers.ts (depth, renderHreflangBlock, fallbackAlternateHref)
- Extract chrome/head.ts (renderChromeHead — SEO, OG, JSON-LD, hreflang)
- Extract chrome/header.ts (buildHeaderHtml — nav, CTA, breadcrumb, hero)
- Extract chrome/footer.ts (buildFooterHtml — columns, badges, scripts)
- Rewrite chrome.ts as thin façade delegating to sub-modules
- Fix `any` type in chrome JSON-LD findIndex (replaced with typed JsonLdNode)
- Add 59 comprehensive tests in chrome-decomposition.test.ts covering:
- Sub-module isolation (no circular deps)
- HTML5 structural correctness
- WCAG 2.1 AA accessibility (skip-link, ARIA, roles)
- RTL language handling (Arabic, Hebrew)
- hreflang for all 14 languages
- JSON-LD injection and XSS prevention
- SEO meta tags (OG, Twitter Cards)
- Language switcher (14 languages)
- Hero banner control
- Pagination rel links
- All 430 existing tests pass (zero regressions)
Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/e1a3c2db-9238-4874-8434-5932e8e4da99
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
---
scripts/render-lib/chrome.ts | 753 ++-------------------------
scripts/render-lib/chrome/footer.ts | 206 ++++++++
scripts/render-lib/chrome/head.ts | 191 +++++++
scripts/render-lib/chrome/header.ts | 161 ++++++
scripts/render-lib/chrome/helpers.ts | 73 +++
scripts/render-lib/chrome/index.ts | 24 +
scripts/render-lib/chrome/types.ts | 123 +++++
tests/chrome-decomposition.test.ts | 507 ++++++++++++++++++
8 files changed, 1322 insertions(+), 716 deletions(-)
create mode 100644 scripts/render-lib/chrome/footer.ts
create mode 100644 scripts/render-lib/chrome/head.ts
create mode 100644 scripts/render-lib/chrome/header.ts
create mode 100644 scripts/render-lib/chrome/helpers.ts
create mode 100644 scripts/render-lib/chrome/index.ts
create mode 100644 scripts/render-lib/chrome/types.ts
create mode 100644 tests/chrome-decomposition.test.ts
diff --git a/scripts/render-lib/chrome.ts b/scripts/render-lib/chrome.ts
index de4b924fb9..ed62828126 100644
--- a/scripts/render-lib/chrome.ts
+++ b/scripts/render-lib/chrome.ts
@@ -4,739 +4,60 @@
* @name Shared HTML chrome (head / header / footer / SEO) for articles
*
* @description
- * Pure, stateless string builder for the `…
` plus
- * `…` plus `…` blocks
- * wrapping every rendered article. **No filesystem access, no markdown
- * parsing** — all inputs are plain strings / POJOs described by
- * {@link ChromeOptions}.
+ * Façade module that delegates to the decomposed bounded-context modules
+ * in `./chrome/` (types, helpers, head, header, footer). Maintains the
+ * same public API as the original monolithic `chrome.ts` so all existing
+ * importers (`article.ts`, `generate-news-indexes/template.ts`,
+ * `sitemap-html/render/page.ts`, etc.) continue to work without changes.
*
- * ## SEO surface
- * - `` · `` · keywords · robots
- * - Open Graph (incl. `og:locale:alternate` for the 13 non-current langs)
- * - Twitter Card
- * - JSON-LD blocks via {@link ChromeOptions.jsonLd}
- * - `hreflang` link rel alternates via {@link renderHreflangBlock}
- * (x-default always points at the English alternate or the canonical
- * path if no English alternate is supplied)
+ * ## Architecture (Round-5 decomposition)
+ * ```
+ * chrome.ts (this file — façade)
+ * └── chrome/
+ * ├── types.ts — ChromeOptions, SiteChrome, BreadcrumbItem
+ * ├── helpers.ts — depth(), renderHreflangBlock(), fallbackAlternateHref()
+ * ├── head.ts — renderChromeHead() — SEO / OG / JSON-LD / hreflang
+ * ├── header.ts — buildHeaderHtml() — nav / CTA / breadcrumb / hero
+ * ├── footer.ts — buildFooterHtml() — columns / badges / scripts
+ * └── index.ts — barrel re-export
+ * ```
*
- * ## Accessibility surface
- * - Skip-link (``)
- * - Semantic `` / ``
- * / `…
+ * ` block including the four-column layout (brand,
+ * navigate, ISMS, compliance), trust badges, secondary language row,
+ * and Mermaid/theme bootstrap scripts.
+ *
+ * @author Hack23 AB (Infrastructure Team)
+ * @license Apache-2.0
+ */
+
+import type { Language } from '../../types/language.js';
+import { LANGUAGE_META, escapeHtml } from '../../generate-sitemap-html.js';
+import { GITHUB_BLOB, LANGUAGES } from '../constants.js';
+import { chromeStrings } from '../chrome-i18n.js';
+import type { ChromeOptions } from './types.js';
+import { depth, fallbackAlternateHref } from './helpers.js';
+
+/**
+ * Build the complete `…