Show HN: Metalsmith – A pluggable static site generator
metalsmith.io
metalsmith.io
It's so well understood and constrained of a problem domain that we can now ignore the practical considerations and go all-out with the art itself. I feel like this design and api is a great example of that, much like Penn and Teller's Cups and Balls with clear cups[1] - wonderfully creative innovation within a completely and totally solved problem domain.
> All of the logic in Metalsmith is handled by plugins.
But on the other hand, you say this:
> Each plugin is invoked with the contents of the source directory, with every file parsed for optional YAML front-matter, like so…
The YAML parsing should be a plugin as well, some of us have existing JSON front-matter files.
Now to build something with this, I can see a 'dual write' plugin in my immediate future...
A possible use case would be generating pages from an RSS feed. You'd have to specify the meta-data separately in some config though.
(Sorry, really don't want to over-design something that seems simple and elegant. Just a thought.)
* I was going to say for "less-technical" folks but then I realized that even technical people shouldn't have to be subjected to our current tangle of Jade files!
Edit: In fact, could this whole thing just be a gulp plugin?
The simplicity is nice because you can read through Metalsmith's source and really understand everything that it's doing very quickly: https://github.com/segmentio/metalsmith/blob/master/lib/inde...
It's also greatly impacted by what plugins choose to do. I had an extra clone call (literally cloning the buffers for each file) in the templating plugin at one point that like 50x'd the build time :) Everything I've done so far though has sub-second build times—quick enough that I've been building on every request[1] in development which makes things super simple.
[1]: https://github.com/segmentio/metalsmith.io/blob/master/serve...
But it’s harder to figure out how to create my own local plugins and make sure Metalsmith is able to see them. And the documentation should make it clearer how to use the JavaScript API, in the context of a static file generator, where most people are not thinking about writing a program. It took me a bit of thinking to realize that you would have to create a `whatever.js` file inside the directory containing JavaScript code with `Metalsmith(".")….build()`, and then just run it with `node whatever.js`.
[1]: https://github.com/segmentio/metalsmith/tree/master/examples
I have a similar weekend project that is aimed towards generating static markup. The syntax looks a bit like haml with simple to use mixins, includes, and variables.
The project scaffold generator part sounds pretty interesting because I needed it pretty often and eventually had to build that for myself.
Documentation - for our docs[1] we want to be able to use the same simple static site generator without having all of the blogging logic. Basically the nesting of the files should result in the nesting of the URLs. But we also want to be able to tie in metadata that we have in our database about all of our integrations. And we'd also like to be able to write custom handlebars helpers that turn a simple JSON object into a widget that renders API calls in any of our supported languages.
Academy - for our academy[2] I really want to get to the point where we can generate PDFs for each of our articles and being to re-distribute them that was as eBooks (or potentially for a collection of articles) because that kind of thing appeals to enterprises who are looking for guidance. And we could even end up doing the same thing with our docs pages. And then we also want to have custom handlebars helpers for
Blog - for our blog[3] we want just the most basic implementation, although maybe with some niceties about author metadata to load in avatars and such.
Whenever you try and get into additional features that weren't considered by the original "static site" (or worse "static blog") generators, you usually end up building really cludgey code, if it's even possible.
So with Metalsmith we avoid all of that, because the plugins can do whatever they want, and it's super trivial to add local plugins to the mix if you're cooking up something which you know is unique to just you.
And the last thing was that we were sick of having a Ruby dependency (with all of the associated slowness) just to build our blog with Jekyll. Basically was increasing build times by an order of magnitude.
[1]: https://segment.io/docs [2]: https://segment.io/academy [3]: https://segment.io/blog