Configuration
You can configure the appearance and behavior of a TutorialKit lesson by setting up properties in the lesson’s frontmatter block.
Note on inheritance
Some options, like “title,” will naturally be unique for each lesson. For others, like “template,” the value might be the same across multiple lessons, chapters, or even an entire tutorial. That’s why we’ve made it possible to set some properties on a chapter, part, or tutorial level. We call these values inherited.
For instance, if you set template: "simple"
for a given part, all chapters and lessons in this part will use the “simple” template.
It’s also possible to override inherited properties on a lower level. For example, if you set template: "simple"
for a part, but template: "advanced"
for a lesson, that specific lesson will use the “advanced” template.
Configuration location
- In case of a lesson, set the configuration in the frontmatter of the
content.md
file. - For a chapter, part or the whole tutorial, set the configuration in the frontmatter of the
meta.md
file on the respective level.
Options reference
type
Defines the type of the metadata.
Required | Values | Inherited |
---|---|---|
yes | 'part', 'chapter' or 'lesson' | no |
title
The title of the part, chapter, or lesson.
Required | Type | Inherited |
---|---|---|
yes | string | no |
slug
Lets you customize the URL segment which is /:partSlug/:chapterSlug/:lessonSlug
Required | Type | Inherited |
---|---|---|
no | string | no |
i18n
Lets you define alternative texts used in the UI. This is useful for localization.
Required | Type | Inherited |
---|---|---|
no | I18nText | yes |
The I18nText
type has the following shape:
focus
Defines which file should be opened in the code editor by default when lesson loads.
Required | Type | Inherited |
---|---|---|
no | string | yes |
editor
Configure whether or not the editor should be rendered. If an object is provided with fileTree: false
, only the file tree is hidden.
Required | Type | Inherited |
---|---|---|
no | boolean | { fileTree: false } | yes |
previews
Configure which ports should be used for the previews allowing you to align the behavior with your demo application’s dev server setup. If not specified, the lowest port will be used.
Required | Type | Inherited |
---|---|---|
no | Preview[] | yes |
The Preview
type has the following shape:
Example value:
mainCommand
The main command to be executed. This command will run after the prepareCommands
.
Required | Type | Inherited |
---|---|---|
no | Command | yes |
The Command
type has the following shape:
prepareCommands
List of commands to execute sequentially. They are typically used to install dependencies or to run scripts.
Required | Type | Inherited |
---|---|---|
no | Command[] | yes |
The Command
type has the following shape:
terminal
Configures one or more terminals. TutorialKit provides two types of terminals: read-only, called output
, and interactive, called terminal
. Note, that there can be only one output
terminal.
You can define which terminal panel will be active by default by specifying the activePanel
value. The value is the given terminal’s position in the panels
array. If you omit the activePanel
property, the first panel will be the active one.
An interactive terminal will disable the output redirect syntax by default. For instance, you cannot create a file world.txt
with the contents hello
using the command echo hello > world.txt
. The reason is that this could disrupt the lesson if a user overwrites certain files. To allow output redirection, you can change the behavior with the allowRedirects
setting. You can define this setting either per panel or for all panels at once.
Additionally, you may not want users to run arbitrary commands. For example, if you are creating a lesson about vitest
, you could specify that the only command the user can run is vitest
by providing a list of allowCommands
. Any other command executed by the user will be blocked. You can define the allowCommands
setting either per panel or for all panels at once.
By default, in every new lesson terminals start a new session. If you want to keep the terminal session between lessons, you can specify the id
property for a given terminal panel and keep the same id
across lessons.
Required | Type | Inherited |
---|---|---|
no | Terminal | yes |
The Terminal
type has the following shape:
Example value:
autoReload
Navigating to a lesson that specifies autoReload
will always reload the preview. This is typically only needed if your server does not support HMR.
Required | Type | Inherited |
---|---|---|
no | boolean | yes |
template
Specifies which folder from the src/templates/
directory should be used as the basis for the code. See the “Code templates” guide for a detailed explainer.
Required | Type | Inherited |
---|---|---|
no | string | yes |
editPageLink
Display a link in lesson for editing the page content.
The value is a URL pattern where ${path}
is replaced with the lesson’s location relative to the src/content/tutorial
.
Required | Type | Inherited |
---|---|---|
no | string|false | yes |
The inherited value can be disabled in specific parts using false
.
openInStackBlitz
Display a link for opening current lesson in StackBlitz.
Required | Type | Inherited |
---|---|---|
no | OpenInStackBlitz | yes |
The OpenInStackBlitz
type has the following shape: