OKAY, this contains a ton of stuff! And I wrote it a while ago, so I have to remember everything I did
/lib/
I broke the site generation into multiple steps:
collect-files.js: looks in a specific directory and recursively gets all of the relative file paths for everything inside. This is more or less wrapper for glob that makes it easier to do things later in the pipeline.
parse-markdown.js: given a markdown file, tries to extract header information such as title, author, date, and tags. Returns all of that metadata, as well as the whole file (as content attribute) in an object.
generate-templates.js: handles the registration of partials and makes the various template functions. It also returns the handlebars object for use down the pipeline. So for example if you have a couple of templates, templates/main.htmltemplates/post.md (which can depend on partials) it returns { handlebars: <handlebars>, main: <function>, post: <function> }. The template functions expect an object with the content attribute (such as from the output of parse-markdown.js), which should be the HTML to go into the page.
feed-generator.js: builds the RSS feed for the posts. Takes the output of parse-markdown.js.
generate-site-dir.js: this puts together the pipeline to generate a full site directory. Anything that's in /content and isn't a parseable file (currently anything other than .md files) gets copied over directly. .md files go through the parse-markdown.js and are applied to the template functions from generate-templates.js to make HTML files which get put written to the same location as the original markdown file.
/test/
A whole bunch of tests for each of the files/steps in the pipeline!
/bin/
A balrog binary which runs generate-site-dir.js with reasonable defaults. This can be run in any folder that has a content directory to generate a site directory. Also expects templates directory, and (optionally) partials directory.
OKAY, this contains a ton of stuff! And I wrote it a while ago, so I have to remember everything I did
/lib/
I broke the site generation into multiple steps:
collect-files.js
: looks in a specific directory and recursively gets all of the relative file paths for everything inside. This is more or less wrapper for glob that makes it easier to do things later in the pipeline.parse-markdown.js
: given a markdown file, tries to extract header information such astitle
,author
,date
, andtags
. Returns all of that metadata, as well as the whole file (ascontent
attribute) in an object.generate-templates.js
: handles the registration of partials and makes the various template functions. It also returns thehandlebars
object for use down the pipeline. So for example if you have a couple of templates,templates/main.html
templates/post.md
(which can depend on partials) it returns{ handlebars: <handlebars>, main: <function>, post: <function> }
. The template functions expect an object with thecontent
attribute (such as from the output ofparse-markdown.js
), which should be the HTML to go into the page.feed-generator.js
: builds the RSS feed for the posts. Takes the output ofparse-markdown.js
.generate-site-dir.js
: this puts together the pipeline to generate a full site directory. Anything that's in/content
and isn't a parseable file (currently anything other than.md
files) gets copied over directly..md
files go through theparse-markdown.js
and are applied to the template functions fromgenerate-templates.js
to make HTML files which get put written to the same location as the original markdown file./test/
A whole bunch of tests for each of the files/steps in the pipeline!
/bin/
A
balrog
binary which runsgenerate-site-dir.js
with reasonable defaults. This can be run in any folder that has acontent
directory to generate asite
directory. Also expectstemplates
directory, and (optionally)partials
directory.