Fix theme-toggle/anti-flash mismatch, Norwegian BCP-47 lang tag, and inline script CSP exposure#829
Merged
pethers merged 2 commits intomain-7a9239b964b147d1from Mar 5, 2026
Merged
Conversation
…cript CSP issue Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add opposition motions articles analysis for March 2026
Fix theme-toggle/anti-flash mismatch, Norwegian BCP-47 lang tag, and inline script CSP exposure
Mar 5, 2026
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.
Three independent bugs in the article generation pipeline, all introduced in recent sub-PRs:
Theme-toggle ↔ anti-flash snippet mismatch
The inline
<script>usedlocalStorage['theme']and toggleddocument.body.classList, while the anti-flash head snippet usesriksdagsmonitor-themeand drivesdocument.documentElement[data-theme]. Result: theme preference never persisted correctly across page loads.Fix: Extracted to
js/theme-toggle.js(external, cacheable) using the same key and same DOM hook:Norwegian BCP-47 language tag
<html lang="no">and"inLanguage": "no"in JSON-LD — inconsistent with the already-correcthreflang="nb"tags on the same page. Template now useshreflangCode(lang)for both attributes, so'no'→'nb'everywhere.Inline script CSP exposure
Moving theme-toggle to an external file eliminates the need for
unsafe-inlinefor this script. Template replaced the 55-line inline block with<script src="../js/theme-toggle.js"></script>.Scope
template.ts— all three fixes, affects all future-generated articles2026-03-05-opposition-motions-*.html— inline script replaced with external reference2026-03-05-opposition-motions-no.html—lang/inLanguagepatched directlynb(notno) for Norwegian output💡 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.