How linychuo/my-blog works
Main Components
• Command-Line Entry Point (main.rs): This module serves as the application’s starting point; it gathers parameters (paths to posts, static files, templates, etc.) and kicks off the build process.
• Core Blog Building Logic (blogger.rs): This module encapsulates the blog generator’s main behavior. It handles rendering of individual posts, generating the index page, and copying over static assets.
• Article Handling (post.rs): This component represents individual articles. It manages parsing markdown content and converting it to an internal representation before rendering.
• Content Directories:
• Posts: Contains original markdown files for each blog post.
• Templates: Contains Handlebars (*.hbs) templates for various parts of the blog (layout, navigation, footer, post page, etc.).
• Static: Contains static resources like CSS, images, and maybe JavaScript.
Relationships and Data Flow
• The entry point (main.rs) reads command-line arguments to determine the directories for posts, static files, and templates, as well as the build output directory.
• It then invokes the blogger module which:
• Iterates over the markdown posts in the “posts” directory.
• Uses post.rs to parse each Markdown file into an article object.
• Passes these articles along with template files from “templates” to the Handlebars engine for HTML rendering.
• Manages the copying of static resources from the “static” folder to the build output.
• The output is a complete static website, stored in the build directory, with HTML files and linked assets.
Architectural Patterns and Principles
• Separation of Concerns: The project is clearly divided into content data (posts), presentation (templates and static assets), and business logic (Rust modules in “src”).
• Pipeline Architecture: There is a clear sequence—input parsing, content transformation (markdown to HTML via templates), and asset management.
• Modular Design: Splitting functionality among different modules (main.rs, blogger.rs, post.rs) ensures each part of the blog generation process is logically isolated.
Technologies and Libraries
• Rust: The core programming language used.
• Handlebars for Rust: The template engine used for rendering HTML from templates.
• Markdown Processing: Although not explicitly mentioned in the file names, an internal mechanism (or a library) is assumed to parse markdown files.
• Command-Line Argument Parsing: Used in main.rs to obtain input paths and configuration constants.
Instructing the Principal Software Engineer to Include the Following
• Input flow from the posts, static, and templates directories into the processing engine.
• Data flow from main.rs to blogger.rs and from blogger.rs to post.rs.
• Output flow from the processing engine into the build directory.