A simple React & fsdb based static site generator.
Check out the sample
directory for a simple example.
The two currently supported formats are:
- Markdown
- YAML
- JSON
For md
files, front-matter is treated as root level data, and all content is inside the data key
---
title: The Obliteration of Man
---
I am God
Which gets compiled to
{
title: "The Obliteration of Man",
body: "\nI am God",
parent: ...
}
The entire layouts folder is required on startup. From there, all registered components are called with their respective nodes and rendered (ie. all nodes with type: book
get rendered by the following React component)
layouts/Book.js
import { Registry } from "@alizain/coconut"
function Book({ node }) {
return (
<h1>{node.title}</h1>
)
}
Registry.set("book", Book)
You can also set a default layout to use for nodes:
Registry.setDefault(Page)
Node layout is determined by the layout
property, then by the type
property. So a node with the following keys, will be rendered using the listing
renderer.
{
layout: "listing",
type: "collection"
}
{
dataDir: "./data", // content/data directory
layoutDir: "./layouts", // React component directory
distDir: "./dist", // compiled HTML output directory
commonFile: "common" // shared props file
}