Static-site generators like bascule are essentially blogging platforms. There's a home page, maybe a couple of other pages, and then an ever-growing list of blog items. Blogs have a title, a date, and pretty much all look alike. They are all driven by the same template - in bascule's case, that template is called
post and it has an associated Handlebars template called
post.hb. That's hard-coded into the system.
That's working fine, but it's not very flexible. You can create as many templates as you like in bascule, but only ones called
post will be considered for page listings, tag generation and so on.
I'd like to change this, for a couple of reasons. In my Dad's website, The Right Notes, the posts alternate between themes (most recently Australia ) and composers (such as Georges Bizet ). But you wouldn't know there was a distinction just by looking at them. I could add additional meta-data fields, or more tags, and then do logic on the single
post.hbs template, but that could get messy and Handlebars isn't really suited to that sort of logic.
I'd like to do a similar split on this website; my new computer game project, Project Herschel, could really do with a regular blog, but I'd love to style it differently from posts like this. After all, Project Herschel is set - in SPACE! - and needs a space-age look-and-feel.
I'm going to add a new project meta-data yaml field, perhaps called
postLayouts. From there you will be able to specify a list of templates which constitute blog-posts. Something like this:
That way any blog file with a layout of either
theme will be rendered with its own unique Handlebars template, but would still be considered a blog post for the purposes of listings, tags and so on. As always with bascule, if
postLayouts is not specified, it will fall back to the sensible default of
post for the blogging template.
There's another problem with bascule, at least for The Right Notes website. That website doesn't display any dates, but the posts are supposed to be ordered: theme, then composer, then back to theme again. The trouble for The Right Notes is that there is no logical date order for this, and the various pages have been uploaded in no particular order. My Dad would like to have some control of how posts are ordered, without relying on dates.
Bascule posts are just plain text files. There is no external meta-data (other than the project definition yaml file). If a date is not specified in the file itself, bascule just grabs the creation date of the file from the file system.
And I'm really not sure how to do it, without adding a whole bunch of complexity to bascule which it doesn't really warrant.