Crate ssg

Source
Expand description

Shokunin logo

ยงShokunin Static Site Generator (SSG)

A content-first static site generator crafted in Rust, optimized for performance, accessibility, and search engine visibility.

Made With Love Crates.io lib.rs Docs.rs Codecov Build Status GitHub

โ€ข Website โ€ข Documentation โ€ข Report Bug โ€ข Request Feature โ€ข Contributing Guidelines

ยงOverview ๐Ÿš€

Shokunin is a high-performance static site generator (SSG) engineered in Rust that prioritises:

  • Content-first development approach
  • Lightning-fast site generation
  • WCAG 2.1 Level AA accessibility compliance
  • Advanced SEO optimization
  • Type-safe operations with comprehensive error handling

ยงKey Features ๐ŸŽฏ

ยงCore Capabilities

  • โšก Exceptional Performance: Zero-cost abstractions through Rust
  • ๐Ÿ“ฑ SEO Optimization: Built-in enhancements for search visibility
  • โ™ฟ Accessibility: Automatic WCAG 2.1 Level AA compliance
  • ๐Ÿ› ๏ธ Multi-format Support: Handles Markdown, YAML, JSON, and TOML
  • ๐Ÿ”„ Feed Generation: Automatic Atom and RSS feed creation
  • ๐Ÿ“Š Analytics: Native Google and Bing Analytics integration
  • ๐ŸŽจ Theming: Custom HTML themes and template support

ยงDevelopment Features

  • ๐Ÿ”ง CLI Tools: Comprehensive command-line interface
  • ๐Ÿš€ Dev Server: Built-in Rust server for local development
  • ๐Ÿ” Hot Reload: Automatic content updates during development
  • ๐Ÿ“ Type Safety: Guaranteed memory and thread safety
  • โšก Async Support: Full asynchronous operation capabilities

ยงGetting Started ๐Ÿ“ฆ

ยงInstallation

Add to your Cargo.toml:

[dependencies]
ssg = "0.0.32"

Or install via Cargo:

cargo install ssg

ยงBasic Usage

use staticdatagen::compiler::service::compile;
use std::{path::Path, error::Error};

fn main() -> Result<(), Box<dyn Error>> {
    // Define directory paths
    let build_dir = Path::new("./examples/build");          // Build directory
    let content_dir = Path::new("./examples/content");      // Content directory
    let public_dir = Path::new("./examples/public");        // Public directory
    let template_dir = Path::new("./examples/templates");   // Templates

    // Generate site
    compile(build_dir, content_dir, public_dir, template_dir)?;
    println!("โœจ Site generated successfully!");
    Ok(())
}

ยงCLI Usage

Create a new site:

# Full command syntax
ssg --content=content --template=templates --serve=public

# Short form
ssg -c=content -t=templates -o=output -s=public

# Using cargo run
cargo run --bin ssg -- -c="./examples/content" -t="./examples/templates" -s="./examples/public"

ยงCLI Options

OptionShortDescriptionRequired
--content-cContent pathYes
--template-tTemplate pathYes
--serve-sServer Public pathYes

ยงExamples ๐Ÿ“š

Try our example implementations:

# Basic example
## Convert Markdown to static sites effortlessly, with templates, organized builds, and instant local hosting.
git clone https://github.com/sebastienrousseau/shokunin.git
cd shokunin
cargo run --example basic

# Quick start example
## Create, compile, and host a static site effortlessly with Shokunin: simple setup, error handling, and instant local server for previews.
cargo run --example quickstart

# Multilingual example
## Build multilingual static sites effortlessly: generate language-specific sites, create a language selector, and serve all from a single directory.
cargo run --example multilingual

ยงDocumentation ๐Ÿ“–

ยงContributing ๐Ÿค

We welcome contributions! Please see our Contributing Guidelines for details on:

  • Code of Conduct
  • Development Process
  • Pull Request Guidelines
  • Issue Reporting

ยงLicense ๐Ÿ“„

This project is dual-licensed under:

at your option.

ยงAcknowledgements ๐Ÿ™

Special thanks to all contributors who have helped build Shokunin.

Re-exportsยง

pub use staticdatagen;

Modulesยง

cmd
Command Line Interface Module
process
Module declarations

Structsยง

Paths
Represents the necessary directory paths for the site generator.
PathsBuilder
Builder for creating Paths configurations

Functionsยง

collect_files_recursive
Recursively collects all file paths within a directory.
copy_dir_all
Recursively copies a directory whilst maintaining structure and attributes.
copy_dir_all_async
Asynchronously copies an entire directory structure, preserving file attributes and handling nested directories.
copy_dir_with_progress
Recursively copies directories with a progress bar for feedback.
create_directories
Creates and verifies required directories for site generation.
create_log_file
Creates and initialises a log file for the static site generator.
handle_server
Configures and launches the development server.
is_safe_path
Checks if a given path is safe to use.
log_arguments
Logs processed command-line arguments for debugging and auditing.
log_initialization
Records system initialisation in the logging system.
run
Executes the static site generation process.
verify_and_copy_files
Validates and copies files from source to destination.
verify_and_copy_files_async
Asynchronously validates and copies files between directories.
verify_file_safety
Verifies the safety of a file for processing.