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
Configures options for the editor and its file tree. Editor can be hidden by providing false
.
Optionally you can hide just file tree by providing fileTree: false
.
File tree can be set to allow file editing from right clicks by setting fileTree.allowEdits: true
.
Required | Type | Inherited |
---|---|---|
no | Editor | yes |
The Editor
type has the following shape:
Example values:
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.
Optionally you can hide the preview by providing previews: false
.
Required | Type | Inherited |
---|---|---|
no | Preview[] | false | 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:
filesystem
Configures how changes such as files being modified or added in WebContainer should be reflected in the editor when they weren’t caused by the user directly. By default, the editor will not reflect these changes.
An example use case is when a user runs a command that modifies a file. For instance when a package.json
is modified by doing an npm install <xyz>
. If watch
is set to true
, the file will be updated in the editor. If set to false
, the file will not be updated.
This property is by default set to false
as it can impact performance. If you are creating a lesson where the user is expected to modify files outside the editor, you may want to keep this to false
.
If you would like files to be added or removed from the editor automatically, you need to specify an array of globs that will determine which folders and files to watch for changes.
Required | Type | Inherited |
---|---|---|
no | FileSystem | yes |
The FileSystem
type has the following shape:
Example values:
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.
You can set terminal open by default by specifying the open
value.
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:
downloadAsZip
Display a button for downloading the current lesson as .zip
file. Defaults to false
.
The default filename is constructed by concatenating folder names of part, chapter and lesson.
Required | Type | Inherited |
---|---|---|
no | DownloadAsZip | yes |
The DownloadAsZip
type has the following shape:
meta
Configures <meta>
tags for Open Graph protocole and Twitter.
TutorialKit will use your logo as the default image.
Required | Type | Inherited |
---|---|---|
no | MetaTagsSchema | yes |
The MetaTagsSchema
type has the following shape:
Example value:
custom
Assign custom fields to a chapter/part/lesson.
Required | Type | Inherited |
---|---|---|
no | Record<string,any> | yes |
This is useful when you want to consume items for the default tutorial
collection
in order to implement custom features.
Configure the Tutorialkit Astro integration
@tutorialkit/astro
is an integration for Astro. You can configure the integration in your astro.config.ts
file.
You can pass the following options to the tutorialkit
integration:
components
type: OverrideComponentsOptions
Provide the path to the components you want to override.
See Overriding Components for details of all the components that you can override.
defaultRoutes
type: boolean | "tutorial-only"
default: true
Controls whether the tutorial routes are automatically added to your project. When set to true
, it additionally adds a redirect from /
to the first tutorial.
Use "tutorial-only"
to only add the tutorial routes without the redirect.