|
|
||
|---|---|---|
| .forgejo/workflows | ||
| sample | ||
| src | ||
| .gitignore | ||
| Cargo.toml | ||
| LICENSE | ||
| README.markdown | ||
MANDY ⚡ 🌸 🎀
A fast and light static-site generator. ⚡ 🌸 🎀
ABOUT 📚
This repository contains the source code for a light and fast static-site generator (SSG) using the Jirai markup language and the JMU data language. The SSG has been optimized to be exceptionally light and exceptionally fast.
INSTALLATION 📥
There are two options for installing Mandy: i) Installing Mandy from source or ii) Downloading and installing one of the pre-compiled binaries.
From source
This guide assumes that you have the following tools installed and available from the command line:
To install Mandy, execute this command from the command line:
cargo install --git https://source.alyxshang.boo/alyxshang/mandy --tag v.0.1.0
From a pre-compiled binary
There a pre-compiled binaries for the following platforms:
- Mac OS for Intel chips: Download the appropriate executable from here, rename it, and place it in a directory on your
$PATH. - Mac OS for Apple chips: Download the appropriate executable from here, rename it, and place it in a directory on your
$PATH. - Debian for 64-bit chips: Download the file ending in
.debfrom here and install it with the commandsudo dpkg -i file_name.deb, wherefile_nameis the name of the file ending in.deb. - Arch Linux for 64-bit chips: Download the file ending in
.pkg.tar.zstfrom here and install it with the commandsudo pacman -U file_name.pkg.tar.zst, wherefile_nameis the name of the file ending in.pkg.tar.zst. - Windows for 64-bit chips: Download the appropriate executable from here, rename it, and place it in a directory on your
$PATH.
CODE REPORT 👩💻
Mandy was built with the explicit purpose of being very light, highly optimized, and very fast. These metrics about the project's code should illustrate this:
- 574 lines of Rust.
- 157 lines of Rust unit tests.
- 697 lines of documentation comments.
- The size of the compiled binary is 455KB.
- The build time for a Mandy project is <400ms.
The previous version of Mandy from two years ago had 4000 lines of code and an executable size of 12MB.
USAGE 🔨
CLI commands
Mandy's CLI offers four commands:
help: Outputs usage information.version: Outputs version information.build /path/to/project: Compiles the Mandy project at the path/path/to/project.clean /path/to/project: Removes the directory and the items at the path/path/to/project/$DIST_DIR. The$DIST_DIRis set via thedist_dirvariable in the configuration file of a Mandy project.
Mandy project structure
The only task of Mandy is to take content written in the Extended Jirai format, some HTML templating code, and a configuration file and use this information to produce a directory containing HTML files and other assets, if specified, and make these available and ready to serve as a fully-functional website. This directory with static HTML files and other assets will henceforth be referred to as a compiled Mandy project.
Each Mandy project contains three types of files:
config.jmu: A file containing simple key-value pairs describing configuration variables for a Mandy project. The format of this file is the Jirai Markup Language.page.layout: This file type describes how the content inside a Mandy project is supposed to be laid out on a finished website.content.ejirai:*.ejiraifiles are the main characters in a Mandy project. They contain the content that a finished website displays. These files are written in the Extended Jirai format.
Configuration files
The configuration file of a Mandy project is written in the Jirai Markup Language format (JMU).
JMU uses simple key-value mappings to store data. Such a key-value mapping looks something like this: "name" >~< "Alyx". Each configuration
file must have a few important fields. Some of these fields can be left
out. A list of the optional and mandatory fields can be found below:
dist_dir: This specifies where the compiled Mandy project is to be placed inside the project directory.copy_files: This field is optional but could be neccessary for copying static files to a compiled Mandy project. Typically, the directories specified here contain images or CSS.iter_content: This field is optional but if used, must contain a list of directories containing iterative content. Such a directory could be calledpostsand could contain posts on a blog.user_config: This field is optional but if used, contains a nested key-value mapping of any other values one might like to use on one's site.
Configuration data can be accessed by using the
{site.config} namespace in layouts.
Layout files
Layout files must be stored in the layouts directory of a Mandy
project and these files determine the layout of the content on a page.
These files must end in the .layout extension and are HTML templates.
The content is rendered through variables inside the template.
These template variables are surrounded by { and }.
If an item is iterated over, the open curly braces and close curly
braces are doubled. The following variables are accessible inside a template:
site.config: This variable allows access to the configuration values of a Mandy project. Thesite.config.iter_content.loop_dircan be looped over, if specified.site.page.data: This variable contains the data of each page. This shall be explained in more detail in the next section.site.page.url: This variable gives one the URL of a content page.site.page.content: This variable contains the HTML content of a page.
Content files
Each content file is written in the Extended Jirai format. This format
has two sections. The first sections contains data and the second
section contains content. The content is written in the Jirai format. The data section is written in the same format as the configuration file. Together, they make up Extended Jirai. Each content file must have this format and must end in the .ejirai file extension. The variables that must be set in the data section are listed below and are accessed in a template via the {page.data} variable:
layout: This variable tells Mandy which layout must be used for laying out the content present in the file. The stem of the layout file is used and Mandy will look for a layout of that name in thelayoutsdirectory automatically.title: The title of the page. A title is always required and important.description: The description of the page. A description is always required and important.user_config: This variable is optional but can be used to store any additional information on the page.
EXAMPLE PROJECTS
- An example Mandy project can be found here: alyxshang/mandy-sample-site.
CHANGELOG ✒️
Version 0.1.0
- Initial release.
- Initial upload to Forgejo.
NOTE 📜
- Mandy ⚡ 🌸 🎀 by Alyx Shang 🖤.
- Licensed under the FSL v1.