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
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions scripts/build-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,20 @@ const files = fs.readdirSync(workshopDir)
.filter(f => f.endsWith('.md'))
.sort();

// Concatenate all markdown with horizontal rule separators
const combinedMarkdown = files
.map(f => fs.readFileSync(path.join(workshopDir, f), 'utf8').trim())
.join('\n\n---\n\n');

const htmlContent = marked(combinedMarkdown);
// Render each file as a closed <details> section with the first heading as <summary>
const htmlContent = files.map(f => {
const markdown = fs.readFileSync(path.join(workshopDir, f), 'utf8').trim();
// Extract plain text of the first heading (strip leading # characters).
// Workshop files use HTML comments (not YAML frontmatter), so the multiline
// regex safely finds the first heading regardless of leading comment lines.
const headingMatch = markdown.match(/^#{1,6}\s+(.+)$/m);
const slug = path.basename(f, '.md').replace(/^\d+-?/, '').replace(/-/g, ' ');
const title = headingMatch
? headingMatch[1].trim()
: slug.charAt(0).toUpperCase() + slug.slice(1);
const content = marked(markdown);
return `<details>\n<summary><h2>${title}</h2></summary>\n${content}\n</details>`;
}).join('\n\n');

// Set up output directory
fs.mkdirSync(distDir, { recursive: true });
Expand Down