Redesign article TOC as a localized sticky sidebar with icons & reading-depth layers#2820
Merged
Conversation
…layers Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pethers
May 29, 2026 08:15
View session
Contributor
🏷️ Automatic Labeling SummaryThis PR has been automatically labeled based on the files changed and PR metadata. Applied Labels: html-css,translation,rtl,size-xs,news Label Categories
For more information, see |
Contributor
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Contributor
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
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.
The article Table of Contents on riksdagsmonitor.com rendered as a full-width vertical block above the body — visually noisy and hard to scan. This reworks it into a sticky left-sidebar TOC matching the euparliamentmonitor.com reference, with semantic icons, reading-depth badges, and full dark/light/RTL + 14-language localization.
Renderer (
scripts/render-lib/article-scannability.ts)generateArticleTocto emit a collapsible<aside>→<details open>→<summary>→<nav>→<ol>sidebar instead of a flat block.SECTION_META(canonical slug →{icon, layer}),SECTION_KEYWORD_FALLBACKSregexes for dynamic slugs, andSECTION_META_DEFAULT(📌/analysis).normalizeSlug()strips therm-prefix and trailing-<digits>so suffixed ids (e.g.rm-risk-assessment-7) map correctly.quick/analysis/intelligence) with localizedtitle/aria-labelviaLAYER_NAME_I18Nfor all 14 languages.Layout (
scripts/render-lib/article.ts)rm-article-layout/rm-article-content), gated by a newrm-article--with-tocmodifier so TOC-less articles keep the flat path..rm-article-toc/.rm-toc-activehooks.Styling (
styles/components/article-scannability.css)minmax(13rem,17rem) minmax(0,1fr)) at ≥1024px; sticky sidebar.Key design point
H2 section
ids are language-stable (assigned from the canonical English scaffold), so icon/layer mapping is id-based and needs no per-language text parsing:Tests & output
tests/article-scannability.test.ts: sidebar disclosure structure, id-based icon/layer assignment (incl.-Nnormalization), default fallback, localized badge labels.TOC text flows through the existing
escapeHtml/headingPlainTexthelpers; icon/layer/label values come from fixed internal maps, so there is no new injection surface.