I might be able to even get rid of the distinction between pages and templates. Templates are just a final transformation step, exactly the same as calling ´site.process´ and having it, say, turn Markdown files into HTML.
I was thinking about how to solve support for Vue templates since these turn a single page into multiple files, including SCSS. And then how would I compile the SCSS if templates are the final step? Removing this distinction would make it possible since there can be any kind of processing afterwards.
I've been working on my static site generator. The architecture is based on very simple principles that allow me to implement perfect type-safety.
There are pages and templates.
Pages are the content of the site. They're loaded by recursively reading the files from a defined folder.
With site.process, any kind of processing for any kind of file format can be added. You can modify page, remove them or add new ones. This also includes registering global variables and helpers by simply adding them to every single page. Really, this one simple function makes anything possible SSGs are used for.
Pages are sent to templates. Since pages are actually all sorts of files (not just Markdown, but also images and stuff), they will be sent to a passthrough template by default that simply outputs the binary data. More formats can be added with a template handler based on the MIME type.
Templates may have a validator function to make sure they receive the metadata they expect. It's a function that returns either the parsed data or an error. Since this is so generic, you can plug in your favorite library.
This will give you helpful errors and provide JSX-based templates with typed props.
And that's the whole thing.