Expand description
§Shokunin Static Site Generator (SSG)
§A Content-First Open Source Static Site Generator (SSG) written in Rust.
Part of the Mini Functions family of Rust libraries.
§Overview
Discover Shokunin: The high-performance, Rust-backed Static Site Generator (SSG) that puts content at the forefront of your web experience.
§Features
Shokunin Static Site Generator (SSG) has several notable features, including but not limited to:
- Speed and Flexibility: Built in Rust, offering optimal performance.
- Built-in Supports:
- GitHub Flavoured Markdown (GFM) for intuitive content creation.
- Integrated support for Google Analytics and Bing Analytics.
- Automated sitemap generation, robots.txt, canonical name (CNAME) records, and custom 404 pages.
- Compatibility: Extensive support for various HTML themes and Premium templates.
- Advanced Features:
- Atom and RSS feeds for blog posts, offering greater discoverability.
- Minified HTML, CSS, and JavaScript files for better performance and SEO.
- Development Server: Comes with a Rust-based local development server for easier debugging and testing.
- Format Support: Comprehensive format support including Markdown, YAML, JSON, TOML, XML, etc.
§Usage
§Command Line Interface (CLI)
The CLI is straightforward. Below are examples to guide you:
# Create a new site named docs
ssg --new=docs --content=content --template=template --output=output --serve=public
or
# Alternative shorter command
ssg -n=docs -c=content -t=template -o=output -s=public
Arguments Explained:
-n
,--new
: Name of the new site to be created. (e.g.,--new=docs
). Defaults todocs
which allows you to publish your site to GitHub Pages.-c
,--content
: Directory containing the website content. (e.g.,--content=content
)-t
,--template
: Directory containing website templates. (e.g.,--template=templates
)-o
,--output
: Directory where generated website files will be saved temporarily. (e.g.,--output=build
)-s
,--serve
: (Optional) Directory from which the website will be served. (e.g.,--serve=public
)
§In your project
To incorporate Shokunin Static Site Generator (SSG) in your Rust project, add the following to your Cargo.toml
:
[dependencies]
shokunin = "0.0.29"
And in your main.rs
:
use ssg::compiler::service::compile;
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Uncomment and replace these paths with your directory paths
// let build_path = Path::new("your_build_directory");
// let site_path = Path::new("your_site_directory");
// let content_path = Path::new("your_content_directory");
// let template_path = Path::new("your_template_directory");
// compile(build_path, content_path, site_path, template_path)?;
Ok(())
}
§Contributing
We welcome contributions! Please see CONTRIBUTING.md for details on how to contribute.
§License
This project is dual-licensed under the terms of both the MIT license and the Apache License (Version 2.0).
Modules§
- The
cmd
module contains functions for the command-line interface. - The
compiler
module contains functions for the compilation process. - The
lang
module contains the language translation functions. - The
languages
module contains the language translation functions. - The
loggers
module contains the loggers for the library. Application logging functionality - The
macros
module contains functions for generating macros. - The
metadata
module contains the metadata functions. - The
models
module contains the structs. - The
modules
module contains the application modules. - The
server
module contains the development server. - The
utilities
module contains utility functions.
Macros§
macro_check_directory
Macromacro_cleanup_directories
Macromacro_create_directories
Macro- Executes a shell command, logs the start and completion of the operation, and handles any errors that occur.
- Generates meta tags based on provided key-value pairs.
macro_generate_rss
Macro- Generates HTML meta tags based on field-value pairs from a metadata HashMap.
- Generates HTML meta tags based on a list of tag names and a metadata HashMap.
macro_get_args
Macro- Macro to log the completion of an operation.
- Macro to log an error.
- Custom logging macro for various log levels and formats.
- Macro to log the start of an operation.
macro_metadata_option
Macromacro_render_layout
Macromacro_serve
Macromacro_set_rss_data_fields
Macro- Writes an XML element to the specified writer.
Functions§
- Function:
run
- Runs the static site generator command-line tool.