An overly simple blog engine, or at least it looks like it.
Most of the tools i see around are either bloated or not extensible. So I tried my luck. This is built to be extensible through an easy inferface "the dom".
-
DO: take as little as work to publish something
-
DO: use markdown to write pages
-
DO: keep all features optional
-
DONT: include any kind of framework~ish dependencies
-
DONT: become unhackable, built, typed or anything smelling complex engineering
-
DONT: handle build, optimization or include mandatory opiniated features
npm install encre
mkdir {layouts,static,posts}
echo '<div id="main"></div>' > ./layouts/index.html
npx draft
npx write
All files in static or posts (except for layouts/*
and posts/*.md
) will be automatically copied to the build directory.
The markdown files provided is parsed with both gray-matter
and marked
.
That's all there is to know.
All layouts fallback to index.html
if no other templates are found.
List of available templates:
layouts/post.html
: template for a single postlayouts/tags.html
: template for the tag indexlayouts/tag.html
: template for a single tag page
Both commands draft
and write
take an optional parameter.
Pass along a .js
file of your choice which is exporting objects and functions as following:
This object is mandatory for the generation of the atom feed. Some fields are mandatory, some aren't.
{
url: string, // the website base url (for generation of absolute links)
title?: string // <title>
subtitle?: string // <subtitle>
rights?: string // <rights>
logo?: string // <logo>
icon?: string // <icon>
author?: string // <author><name>
email?: string // <author><email>
uri?: string // <author><uri>
categories?: string[] // will be serialized into a bunch of <category />
}
This function is handling mutation of the document.head
according to given metadata.
The metadata are the fields placed in the yaml header descriptor of your markdown file, or undefined for the index page (so you only need to define default values to handle the index).
This function is made to generate the list of posts in the index file. You will need to generate a dom string according to the given array. This array contains all the posts metadata, as written in the yaml header descriptor of each file.
This function involves generating the title of a post from its metadata. Again, return a dom string representing the post's title. This metadata object contains all the fields written in the yaml header descriptor of each file.
This function is used to generate the list of tags and their associated posts. As usual return a dom string to be inserted. The structure will contain the metadata of each post for each tag.
This function is used to generate the list of posts for one particular tag. Return a dom string to be inserted. The structure will contain the metadata and the name of the tag.