How mandava/pagebrew works
And outline the main components
• CLI/Command Interface – Representing the entry point that accepts user commands (e.g., “npx pagebrew serve/build/preview”). Use the bin/cli.js file as the CLI’s code base.
• Static Site Generator Core – This comprises several sub-components:
– Markdown Parser (src/markdown.js): Handles converting Markdown content to HTML.
– Generator (src/generator.js): Orchestrates the process of scanning input directories (like examples and user-provided markdown files), invoking the markdown parser, and calling the templating engine.
– Server (src/server.js): Provides local server functionality for live previewing.
– Theme Files (under src/themes/aurora, src/themes/frappe, src/themes/minimal): Each theme has its own EJS templates, CSS files (often with Tailwind pre-configurations), and partials (header.ejs, footer.ejs, etc.).
– Configuration Files (e.g., src/pagebrew.config.json and pagebrew.config.json present in examples): These determine rules for the site such as theme selection, output directory, and menu items.
• File System / Content Repository – Represent how markdown files (like index.md, about.md, and content within blog directories) are read from the project’s file tree. Component boundaries should also include the examples directory which provides demos.
• Build/Output Process – This involves writing the generated files to an output directory (as specified in the config, by default "dist").
Out interactions and data flow
• The Generator then reads the Markdown files from the file system, feeding them through the Markdown Parser.
• Output from parsing the Markdown is passed into the Templating Engine, which uses EJS templates – these templates are chosen based on the theme configuration.
• Tailwind CSS plays a role in styling the resulting HTML. Denote that Tailwind is integrated into the theme assets.
• Finally, the rendered HTML files are written to the output directory.
• For local previewing, the Server component serves the generated static site, allowing the user to see the site in a browser.
Architectural patterns and technologies
• Modular Design – Clearly separate responsibilities between CLI, file parsing, templating, and serving.
• Configuration-Driven Customization – The system depends on configuration files (pagebrew.config.json, theme-specific configs) to control behavior.
• Template-based Rendering – Use of EJS templates facilitates layout reuse and theme swapping.
• Integration with Tailwind CSS – Shows the styling aspect managed via dedicated configuration files (e.g., tailwind.config.js in multiple theme directories).