Jikji is a small toolkit for building your own static site generators on Deno.
Currently, it provides the below composable building blocks:
import {
intoDirectory,
scanFiles,
rebase,
writeFiles
} from "https://deno.land/x/jikji/mod.ts";
import { markdown } from "https://deno.land/x/jikji/markdown.ts";
const baseUrl = new URL("http://localhost:8000/");
const outDir = "public_html";
// Scans for Markdown files in the posts/ directory:
await scanFiles(["posts/**/*.md"])
// Renders posts written in Markdown to HTML:
.transform(markdown(), { type: "text/markdown" })
// Makes permalinks like posts/foobar/ instead of posts/foobar.md
.move(intoDirectory())
// Maps the current directory to the target URL <https://example.com/>:
// E.g., ./posts/foobar.md -> https://example.com/posts/foobar/
.move(rebase("posts/", baseUrl))
// Writes the files to the output directory (public_html/):
.forEach(writeFiles(outDir, baseUrl));
// If you want watch mode, use forEachWithReloading() instead:
// .forEachWithReloading(writeFiles(outDir, baseUrl));
More realistic examples are placed in the examples/ directory.
Building blocks that Jikji provides are based on the following concepts:
Pipeline
represents the entire steps from the input to the output.Resource
s. Its whole process isPipeline
is acquired using scanFiles()
scanFiles()
does not immediately list files nor loadResource
represents an abstract resource which is mapped to a uniquepath
. Its path
is a rather URL than a filesystem path, which meanshttps
or file
and can end with a slash.intoDirectory()
function turns posts/foobar.md intoResource
also can has multipleContent
represents an actual content which can belong to Resource
sContentBody
can be lazily loaded and eitherMediaType
sLanguageTag
to describe their natural language. If you wantmetadata
like title
or published
as well.ResourceTransformer
transforms a Resource
into a modified Resource
.Resources
into new ones in immutable stylePipeline#map()
method.PathTransformer
transforms a URL
into a modified URL
. It purposesResource
s path
s into new ones in immutable style byPipeline#move()
method.intoDirectory()
and rebase()
functions returnPathTransformer
s.)ContentTransformer
transforms a Content
into a modified Content
.Resource
s into new onesPipeline#transform()
method.markdown()
function returns aContentTransformer
.)See also API docs.
See CHANGES.md.
Distributed under LGPL 3.0.