Core Concepts

Entrypoint

Learn how to set up the entrypoint for your Maudit project.

At the core of a Maudit project is the coronate function. This function starts the build process and generates the output files. It is the entrypoint to your project and is where you'll pass the pages, content and options that make up your website.

In a main.rs file, import the coronate function and call it to build your project. Here is an example of a simple Maudit project:

use maudit::{coronate, routes, BuildOptions, BuildOutput, content_sources};
use routes::Index;

fn main() -> Result<BuildOutput, Box<dyn std::error::Error>> {
  coronate(routes![Index], content_sources![], BuildOptions::default())
}

Registering Routes

All kinds of routes must be passed to the coronate function in order for them to be built.

The first argument to the coronate function is a Vec of all the routes that should be built. For the sake of ergonomics, the routes! macro can be used to create this list.

use maudit::{coronate, routes, BuildOptions};
use routes::Index;

fn main() {
  coronate(
    routes![Index],
    content_sources![],
    BuildOptions::default()
  )
}

See the Routing documentation for more information on how to define routes.

Content

The second argument to the coronate function is a list of content sources. Content sources are used to load content and data from various sources, such as the filesystem (ex: a folder of markdown files), a database, or a remote API.

use maudit::content::content_sources;

fn main() {
  coronate(
    routes![
      // ...
    ],
    content_sources![
      "source_name" => loader(...),
    ],
    Default::default()
  );
}

See the Content documentation for more information on how to define content sources.

Options

The third argument to the coronate function is a BuildOptions struct. This struct contains various options that can be used to customize the build process.

use maudit::BuildOptions;

coronate(
  routes![
    // ...
  ],
  content_sources![
    // ...
  ],
  BuildOptions {
    output_dir: "public".into(),
    ..Default::default()
  }
);

For a full list of options, see the BuildOptions reference.