Templating
MarkdownSPA uses tera, allowing you to create a base template for all generated pages:
| Variable | Available in | Description |
|---|---|---|
{{ uri }} | Base and nav templates | URI of the page |
{{ meta }} | Base and nav templates | Mapping of the page’s attributes |
{{ base_url }} | Base and nav templates | Either / or prod_url |
{{ page_content }} | Base template | HTML content of each markdown file |
Extra meta attributes must be written at the top of each markdown file:
[title]: # (This is a title)
[summary]: # (This is a description)
This is the actual content of the rendered page.
Then, in the base template, those attributes will be accessible through the meta variable:
<div id="app">
<h1>{{ meta.title }}</h1>
<details>
<summary>{{ meta.summary }}</summary>
{{ page_content }}
</details>
</div>
In this specific case, the template will render as:
<div id="app">
<h1>This is a title</h1>
<details>
<summary>This is a description</summary>
<p>This is the actual content of the rendered page.</p>
</details>
</div>