Variables
In umejs, you can reference variables. They can either be generated by code (see config/helpers to learn more), defined statically or defined by umejs. Here we'll go more in-depth about the latter two.
Tip
It's possible to escape variables if you want to show them, for example
{title}. You can do this by adding a backslash (\) in front of the first curly bracket{:\{variableName}
Custom static variables
umejs uses a frontmatter-styled format to parse variables. You can reference these variables anywhere within umejs. Frontmatter is formatted as yaml and is opened with 3 - hypens and closed with another 3. For example, here's how you would define a title and an author:
---
title: 'Awesome blog'
author: 'John Wick'
---
# {title}
Written by {author}
Again, these can be used anywhere within umejs. You could for example use the title as <title> in your template:
<!-- layout.ume.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{title}</title>
</head>
<body>
{_BODY}
</body>
</html>
Built-in variables
umejs also has the following default variables. Trying to set a value to these values will result in an error and prevent said file from being built. Apart from {_BODY}, these variables can be used anywhere. ({_BODY} can only be used in your template file).
| Variable | Result |
|---|---|
{_BODY} |
The entire contents of the Markdown page |
{_SLUG} |
The name of the current slug, e.g. variables |
{_TEST} |
Outputs Markdown code to test the rendering |
{_BASE} |
The base URL where umejs is operating within |