ForgeStaticGen Module

Overview

ForgeStaticGen is a powerful static site generator module for the Forge Framework. It works seamlessly with ForgeMarkDown to convert Markdown files into static HTML websites, providing a simple yet flexible way to generate static content.

Features

  • Markdown Integration: Built-in support for Markdown through ForgeMarkDown
  • Flexible Output: Customizable output directory structure
  • Command Line Interface: Easy-to-use CLI commands for generation
  • Template Support: Custom templates for consistent styling
  • Asset Management: Automatic handling of static assets

Configuration

Configure ForgeStaticGen through the module's configuration file:

// config/forge_static_gen.php
return [
    'output_dir' => 'public/static',
    'templates_dir' => 'templates',
    'assets_dir' => 'assets',
    'markdown_extensions' => ['.md', '.markdown']
];

output_dir: Directory where generated static files will be stored

templates_dir: Directory containing HTML templates

assets_dir: Directory for static assets like CSS, JS, images

markdown_extensions: File extensions to process as Markdown

Usage

Using ForgeStaticGen in your application:

use Forge\Modules\ForgeStaticGen\ForgeStaticGen;
use Forge\Modules\ForgeMarkDown\ForgeMarkDown;

// Initialize the static generator
$markdownParser = new ForgeMarkDown();
$staticGen = new ForgeStaticGen($markdownParser, 'public/static');

// Add content and generate
$staticGen->addContent('docs/example.md', 'templates/docs.html');
$staticGen->generate();

CLI Commands

ForgeStaticGen provides CLI commands for easy site generation:

# Generate static site
php forge static:build

# Clean output directory
php forge static:clean

# Watch for changes and rebuild
php forge static:watch

Note: The watch command is useful during development as it automatically rebuilds the site when source files change.