Mantis: Static Site Generator

Mantis is a still, simple Node.js site generator

Docs

Commands

mantis init

This command will create the general site's folder structure on the current directory.

mantis serve

Mantis will build the site and listen to any changes made on /site directory to work in a live server. Be aware that every change will rebuild the site, erasing anything that was on the /build directory.

mantis build

Mantis will build the web based on the /site directory folder structure

config file

The config file lives in the root directory y has the following shape:

The site.config.js should be as follows:

export default {
  srcPath: './site',
  destPath: './build',
  site:{
    title: 'Mantis SSG',
    /.../
  }
}

If you want to add more data general data, remember to include it within the site property and render it accordingly with EJS, for instance:

<html>
  <body>
  <p><%- site.author %></p>
    <%- body %>
  </body>
  <a href="<%- site.link %>">My link</a>
</html>

Layout

This static site generator is build with EJS. Each theme can have different layouts, to refer to them put its name at the top of the front matter. Every layout should have a <%- body %> tag within it.

Pages

Pages can be built with EJS, Markdown o plain HTML. Every page will be build as an index.html withtin its own directory, wether is specified or not.

If you need to add more specific data to any of your pages, add the next block at the top of the file:

---
template: default
date: 20-01-2023
tags:
  - games
  - stuff
  - tips
---

Any data that is put within the front matter will be accesible through each template with the page attribute:

<html>
  <body>
  <p><%- page.date %></p>
    <%- body %>
    <div>
    <% if (page.tags) { %>
        <% page.tags.forEach(function(tag) { %>
        <span><%= tag %></span>
        <% }) %>
    <% } %>
    </div>
  </body>
</html>

Partials

Partials are small pieces of code meant to be reusable. To insert any of this blocks within pages:

<%- include('partials/block') %>