Casey DeLorme

staticmd

I looked at some alternatives such as harpjs and hugo, and while both of them are fantastic tools, I wanted something much more basic.

I feel that the moment the content for a website has the need for configuration files, you are no longer building a basic static site but a dynamic site with a print release system. While there is nothing inherently wrong with this approach, it seems overkill for a number of projects I’d like to build.

My goal with this code was not just a basic static site generator, but the ability to compile many files into a single “book”. Ideally the ability to do so using a single template file, and with nothing more complicated than a handful of variables inside it.

design considerations

The code needed two paths, one for making a single page book, and one for making a multi page site. There also needed to be a split in the path for multi page generation that allowed for relative paths, so it could be used/accessed like locally generated documentation.

I was also creating this as a work-project, and had a deadline to meet. So I dropped some of the objectives from the original design, such as multiple index support, and some of the navigation logic was changed when I looked at how some others were doing it, like Steve Losh.

future plans

I have a few things I’d like to refactor, features to add, and components to rebuild:

The core of the system which currently accepts cli inputs could be adjusted such that the cli logic is independent. This would allow me to, in the future, create a graphical interface version (ex. staticmd-sdl). It’s something I’ve experimented with in my level6 project.

I have several concerns with the current implementation that generates indexes or table-of-contents. For the single page code I never created a means to sort the contents (it assumes file system order which should be alphabetical). This also means the title of the section, which should point to the index, is not a link because the order it lists the content is not controlled (linking would potentially put you in the middle of that sub-section of content). The multi page index generation currently has to go through extra rounds when using relative links, and like before control over order is only by name. Ideally I want to be able to sort via folders-first for multi-page generation, and some alternative for single-page that allows more control over the order. Fixing how the content builds when using single page such that index contents are the first loaded in sub-sections, and being able to link to them would be ideal.

I want to revisit and cleanup how I create the list of files, folders, and apply filters such as the accepted markdown file types, or which paths to ignore. Right now the code and the way the logic is split does not feel efficient. I’d like to make it more readable, without killing performance.

While my original concept was to avoid configuration files, I am seeing where the need arises. If filtered paths, accepted file types, and a bunch of other properties become flagged options, the command to insert all of this becomes just as complicated as a configuration file. I would like to do what I can to allow configuration file support, with flags for the same set of options, and fallback to a set of sane default values otherwise.

references

I’ve been fond of reading about game development lately, and came across gameprogrammingpatterns.com/, which was written using markdown. This is primarily because the best practices we use in our field today so greatly conflict with game developments version of best practices where performance far outweighs the value of things like object-oriented-design.

Another great resource I found was the golang book, which is also written in markdown. I find great beauty in the simplest of aesthetics, and this is a perfect example of that.

written on 2014-12-22