Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,786 changes: 11 additions & 1,775 deletions scripts/build-docs.js

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions scripts/lib/alerts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Alert callout styles for GitHub GFM > [!NOTE] / [!TIP] / etc. */
.markdown-alert {
padding: 0.5rem 1rem;
margin-bottom: 16px;
border-left: 0.25em solid;
border-radius: 6px;
}
.markdown-alert > :first-child { margin-top: 0; }
.markdown-alert > :last-child { margin-bottom: 0; }
.markdown-alert-title {
display: flex;
align-items: center;
font-weight: 600;
margin-bottom: 4px;
}
.markdown-alert-title svg { margin-right: 8px; }
.markdown-alert-note {
border-color: var(--borderColor-accent-emphasis, #0969da);
background-color: var(--bgColor-accent-muted, #ddf4ff);
}
.markdown-alert-note .markdown-alert-title { color: var(--fgColor-accent, #0969da); }
.markdown-alert-tip {
border-color: var(--borderColor-success-emphasis, #1a7f37);
background-color: var(--bgColor-success-muted, #dafbe1);
}
.markdown-alert-tip .markdown-alert-title { color: var(--fgColor-success, #1a7f37); }
.markdown-alert-important {
border-color: var(--borderColor-done-emphasis, #8250df);
background-color: var(--bgColor-done-muted, #fbefff);
}
.markdown-alert-important .markdown-alert-title { color: var(--fgColor-done, #8250df); }
.markdown-alert-warning {
border-color: var(--borderColor-attention-emphasis, #9a6700);
background-color: var(--bgColor-attention-muted, #fff8c5);
}
.markdown-alert-warning .markdown-alert-title { color: var(--fgColor-attention, #9a6700); }
.markdown-alert-caution {
border-color: var(--borderColor-danger-emphasis, #d1242f);
background-color: var(--bgColor-danger-muted, #ffebe9);
}
.markdown-alert-caution .markdown-alert-title { color: var(--fgColor-danger, #d1242f); }
41 changes: 41 additions & 0 deletions scripts/lib/docs-css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot split this file in .css files as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The CSS template literals have been extracted into two standalone source files:

  • scripts/lib/alerts.css — alert callout styles
  • scripts/lib/docs.css — full workshop SPA styles

docs-css.js now reads them with fs.readFileSync at build time. generateHljsCss() stays in JS since it must compose content from npm packages at runtime. All 8 tests pass (commit refactor: extract CSS template strings into .css source files).


const fs = require('fs');
const path = require('path');
const { prefixCssSelectors } = require('./utils');

// Generate alert callout CSS for marked-alert GFM rendering
function generateAlertsCss() {
return fs.readFileSync(path.join(__dirname, 'alerts.css'), 'utf8');
}

// Generate highlight.js syntax highlighting CSS (GitHub light + dark themes).
// The dark theme rules are scoped to the data-color-mode="dark" attribute and
// to the prefers-color-scheme: dark media query for data-color-mode="auto".
function generateHljsCss() {
const hljsStylesDir = path.join(__dirname, '..', '..', 'node_modules', 'highlight.js', 'styles');
const hljsLightCss = fs.readFileSync(path.join(hljsStylesDir, 'github.min.css'), 'utf8');
const hljsDarkCss = fs.readFileSync(path.join(hljsStylesDir, 'github-dark.min.css'), 'utf8');
return [
'/* highlight.js \u2013 GitHub light theme (default) */',
hljsLightCss,
'',
'/* highlight.js \u2013 GitHub Dark theme (terminal blocks) */',
prefixCssSelectors(hljsDarkCss, '.terminal-block'),
'',
'/* highlight.js \u2013 GitHub Dark theme (explicit dark mode) */',
prefixCssSelectors(hljsDarkCss, 'html[data-color-mode="dark"]'),
'',
'/* highlight.js \u2013 GitHub Dark theme (system dark preference) */',
'@media (prefers-color-scheme: dark) {',
prefixCssSelectors(hljsDarkCss, 'html[data-color-mode="auto"]'),
'}',
].join('\n');
}

// Generate docs CSS \u2013 link discoverability and workshop SPA styles
function generateDocsCss() {
return fs.readFileSync(path.join(__dirname, 'docs.css'), 'utf8');
}

module.exports = { generateAlertsCss, generateHljsCss, generateDocsCss };
Loading