Architecture
An overview of how Saga works.
Overview
Saga does its work in multiple stages.
- Any registered
beforeRead(_:hooks run first — use these for pre-build steps like CSS compilation.) - For every registered step, Saga passes the input files to a matching
Reader. These readers turn text files (such as Markdown files) intoIteminstances. - Saga runs all the registered steps again, now executing the
Writers. These writers turn a rendering context (which holds theItemamong other things) into aStringusing a “renderer”, which it’ll then write to disk, to theoutputfolder. - Then, any registered
afterWrite(_:hooks run — use these for post-build steps like search indexing.) - Finally, all unhandled files (images, CSS, raw HTML, etc.) are copied as-is to the
outputfolder.
Saga does not come with any readers or renderers out of the box. The official recommendation is to use SagaParsleyMarkdownReader for reading Markdown files using Parsley, and SagaSwimRenderer to render them using Swim, which offers a great HTML DSL using Swift’s result builders.
Check GetSaga.dev for a complete list of available plugins, or browse the saga-plugin tag on GitHub.
Check out the Example project to get an idea of how Saga works with Parsley and Swim.