- handmade
- minimalist
- a work in progress (version
4.3.0
) - experimental
- fredmercy.ca
- The website is built using a collection of functions I call Zorg.
- The website is built from source files found in
src/
- The content is in
src/content
& the theme is insrc/theme
:- content items are written in Markdown
- HTML views/components are written in HandlebarsJS
- styles are written in Sass
- JavaScript files are written in plain JS (no transpiling nor bundling) and use JS Modules
- It's built on top of an ExpressJS server:
- when developing, the
npm start
command will build, serve, and watch for changes in source files - to run on the production server, use
npm run serve
- an
.env
file can be used to specifyHOST
andPORT
for Express
- when developing, the
- The compilation of theme assets is handled by the following files:
zorg/assets.js
: simply copies files from the source folder to the./public
destination folderzorg/sass.js
: uses thesass
package to compile styleszorg/websites.js
: uses Zorg to gather the content and process it
- The
zorg/index.js
file is the entry point where all the building and watching takes place. - The
zorg/website.js
file takes care of the content file, by using Zorg (thezorg/lib/zorg.js
file)- The website configuration and the
adapters
(explained below) are specified inside thezorg/website.js
file. - Zorg fetches the content specified by the website's configuration object, and applies each adapter to the content items in series, each one processing the content item in a certain way.
- The website configuration and the
Adapters are functions that are passed the list of content files Zorg finds:
* the zorg/adapters/default-meta.js
file sets up the default array of items (see below)
Here's an example of an item for a content file src/content/thing.md
, after it was processed by zorg/adapters/default-meta.js
:
---
title: A thing!
description: These are things
---
_Hello World!_
{
_info: {
src: "./src/content/thing.md",
updated: "2021-04-20 @ 4:20pm",
built:"2021-04-20 @ 4:20pm"
},
meta: {
baseURL: "/",
lang: "en",
id: "thing",
type: "page",
title: "A thing!",
description: "These are things",
draft: false
},
body: "_Hello World!_"
}
The example above can't build a website yet.
But a few more adapters will get us there:
zorg/adapters/page-meta.js
- adds some properties to
item.meta
, for example:item.meta.url
(inferred from the source file's path)
- adds some properties to
zorg/adapters/markdown.js
- uses the
marked
package to format the string found initem.body
, and adds anitem.content
property with the rendered HTML string.
- uses the
zorg/adapters/html.js
- uses HandlebarsJS to generate an
index.html
, and writes it inside a folder specified byitem.meta.url
. We pass the entireitem
object as data to the HandlebarsJS template.
- uses HandlebarsJS to generate an
To sum up: if we use the adapters default-meta
, page-meta
, markdown
, and html
, our content files will be processed and rendered as HTML in the ./public
folder.