MarkBind provides multiple templates to help users quickly set up their projects. When initializing a new MarkBind project, you can use the --template <template-key>
flag to specify a template during markbind init
These templates are stored in packages/core/template
.
Currently, there are 4 existing templates to choose from:
These template files are used by the Template Class when doing initialization of a markbind project. (markbind init
).
The Template
class is under core/src/Site
, and handles the generation of a site from a template.
When init
function calls the template.init()
function it first validates the template option, then it simply copies the files into the existing directory.
The markbind templates are located in core/src/template
. Upon initalization, it checks that the template option chosen does exist in the given directory.
If the --convert
flag is given in the cli, the program will attempt to convert existing files into a markbind project.
I believe that the primary use case for this is to convert a GitHub Wiki into a MarkBind project. For example, consider cloning Font-Awesome's GitHub Wiki and running markbind init --convert
.
Essentially, it collects all pages, adds an index and about page, adds a default layout file that references all the existing markdown pages and builds the inital markbind template.
init
ProcessTemplate.init(root, options)
.Template
class validates the template by checking if required files exist (validateTemplateFromPath
).fs.access
and fs.mkdirSync
).fsUtil.copySyncWithOptions
).convert
ProcessTemplate.convert()
.Template
class reads the site configuration (SiteConfig.readSiteConfig
).collectNavigablePages
).README.md
or Home.md
to index.md
(fs.copy
).about.md
if it doesn’t exist (fs.outputFile
).fs.readFileSync
).VariableRenderer.compile
and render
).fs.writeFileSync
).addDefaultLayoutToSiteConfig
).fs
: Handles file system operations like reading, writing, and copying files.SiteConfig
: Manages the site configuration (site.json
).VariableRenderer
: Compiles and renders layout templates.logger
: Logs information and warnings duri