retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.02k stars 201 forks source link

Variables #619

Closed 1moskalenko closed 10 months ago

1moskalenko commented 10 months ago

It would be helpful to have entities like variables in the documentation.

Issue:

The documentation's version number could serve as a good example of a variable. It's easy to modify it in a configuration file (under "branding"), but controlling changes to the version number within the documentation text can be challenging.

Possible solution:

Include variables in the configuration file and enable their use within the documentation text. This way, there would be no need to manually locate and modify the version number within the text; simply updating the variable in the configuration file would be enough.

Variables can include custom names, contacts, links, version numbers, etc.

geoffreymcgill commented 10 months ago

You can add custom variables to your Project or Page using the data config. For example, setting a Project with version variable would be configured using the following:

data:
  version: v1.0
  contact: Frank

Then in any page, you can access the variable using the syntax {{ version }}. The following markdown sample demontrates:

Release: {{ version }}
Contact: {{ contact }}

The data config works exactly the same in the Page metadata if you only want access to the value on the Page and not project wide.

In an upcoming release, we will be including many other project, page, and environment variables. The following list is planned:

Name Description
project.* configuration variables from retype.yml
page.* metadata and content of current page
navigation.* list of all pages and sections
git.* git-related information, if available

Hope this helps.