Repository navigation
Enable the CSP (security.csp) in docs and courses, remove what it would block - #12
Merged
Merged
Conversation
- Shiki code blocks: a transformer turns the inline styles into classes
(packages/styles/src/shiki.{mjs,css}).
- Progress bars: width via data-width, applied from a bundled script in
AppShell; DocsHero status dot: box-shadow moved to a class.
- QuizToggle, Tabs, Hint, Quiz and ChatWidget: is:inline/define:vars
scripts become bundled scripts (Astro does not hash body inline
scripts); data moves to data attributes. The stored quiz visibility is
applied by AppShell's head script, so it holds before first paint.
Astro only reads csp inside security; the top-level key was silently ignored, so both sites shipped without a CSP. Google Fonts is allowed as a style source for AppShell's Inter stylesheet.
Deploying knowledge-core with
|
| Latest commit: |
d60cb77
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://773bb8e4.knowledge-core.pages.dev |
| Branch Preview URL: | https://fix-csp-security-config.knowledge-core.pages.dev |
Deploying knowledge-core-docs with
|
| Latest commit: |
d60cb77
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://81c1ff6d.knowledge-core-docs.pages.dev |
| Branch Preview URL: | https://fix-csp-security-config.knowledge-core-docs.pages.dev |
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.
What was wrong: both
apps/docsandapps/courseshadcsp: { algorithm: 'SHA-256' }at the top level ofastro.config.mjs. Astro 6/7 only reads it undersecurity.csp, so the key was silently ignored and neither site shipped a CSP.What changed
security.cspin both configs, withhttps://fonts.googleapis.comas an extra style source (AppShell loads Inter from Google Fonts).shikiStyleToClasstransformer (packages/styles/src/shiki.mjs) turns the inline token styles into classes defined inshiki.css(github-dark), imported byprose.css.ProgressBar,CourseCard,LessonNav):data-width, applied via CSSOM from a bundled script inAppShell;TotalProgressstarts atw-0. DocsHero status dot: box-shadow moved to a class.is:inline/define:varsscripts in the body, soQuizToggle,Tabs,Hint,QuizandChatWidgetnow use bundled scripts (data via data attributes, event delegation /astro:page-load). The stored quiz visibility is applied in AppShell's head script (hashed), so hidden quizzes stay hidden from the first paint.How tested
pnpm check,pnpm type-check(0 errors/warnings/hints),pnpm test(67 tests pass),pnpm build:docs,pnpm build:coursesmain: 2,556 elements, 0 differencesPUBLIC_CHAT_ENDPOINTset (opens, posts to the endpoint, shows the error)Known remaining message: on ClientRouter navigations Astro's router inserts
<script src="data:application/javascript,">as a sentinel, which the CSP blocks (console message only; navigation and scripts work).Not deployed yet.