tutorialkit
Version:
Interactive tutorials powered by WebContainer API
150 lines (118 loc) β’ 7.37 kB
Markdown
# TutorialKit Starter
π Welcome to TutorialKit!
This README includes everything you need to start writing your tutorial content quickly.
## Project Structure
```bash
.
βββ astro.config.mjs # TutorialKit uses Astro π (https://astro.build)
βββ src
β βββ ...
β βββ content
β β βββ tutorial # Your tutorial content lives here
β βββ templates # Your templates (see below for more information)
βββ public
β βββ favicon.svg
β βββ logo.svg # Default logo used in top left for your tutorial
βββ ...
βββ theme.ts # Customize the theme of the tutorial
βββ uno.config.ts # UnoCSS config (https://unocss.dev/)
```
## Getting Started
Make sure you have all dependencies installed and started the dev server:
```bash
<% pkgManager %> install
<% pkgManager %> run dev
```
## UI Structure
```markdown
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β β β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ€
β β β
β β β
β β β
β β β
β β Code Editor β
β β β
β β β
β β β
β β β
β Content βββββββββββββββββββββββββββ€
β β β
β β β
β β Preview & Boot Screen β
β β β
β β β
β βββββββββββββββββββββββββββ€
β β β
β β Terminal β
β β β
βββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ
```
## Authoring Content
A tutorial consists of parts, chapters, and lessons. For example:
- Part 1: Basics of Vite
- Chapter 1: Introduction
- Lesson 1: Welcome!
- Lesson 2: Why Vite?
- β¦
- Chapter 2: Your first Vite project
- Part 2: CLI
- β¦
Your content is organized into lessons, with chapters and parts providing a structure and defining common metadata for these lessons.
Hereβs an example of how it would look like in `src/content/tutorial`:
```bash
tutorial
βββ 1-basics-of-vite
β βββ 1-introduction
β β βββ 1-welcome
β β β βββ content.md # The content of your lesson
β β β βββ _files # Initial set of files
β β β β βββ ...
β β β βββ _solution # Solution of the lesson
β β β βββ ...
β β βββ 2-why-vite
β β β βββ content.md
β β β βββ _files
β β β βββ ...
β β βββ meta.md # Metadata for the chapter
β βββ meta.md # Metadata for the part
βββ 2-advanced
β βββ ...
β βββ meta.md
βββ meta.md # Metadata for the tutorial
```
### Supported Content Formats
Content can be either written as Markdown (`.md`) files or using [MDX](https://mdxjs.com/) (`.mdx`). Files have a Front Matter at the top that contains the metadata and everything that comes after is the content of your lesson.
**Example**
```markdown
type: lesson
title: Welcome!
# Welcome to TutorialKit!
In this tutorial we'll walk you through how to setup your environment to
write your first tutorial π€©
```
The metadata file (`meta.md`) of parts, chapters, and lessons do not contain any content. It only contains the Front Matter for configuration.
### Metadata
Here is an overview of the properties that can be used as part of the Front Matter:
| Property | Required | Type | Inherited | Description |
| --------------- | -------- | --------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| type | β
| `part \| chapter \| lesson` | β | The type of the metadata. |
| title | β
| `string` | β | The title of the part, chapter, or lesson. |
| slug | | `string` | β | Letβs you customize the URL pathname which is `/:partSlug/:chapterSlug/:lessonSlug`. |
| previews | | `Preview[]` | β
| Configure which ports should be used for the previews. If not specified, the lowest port will be used. |
| autoReload | | `boolean` | β
| Navigating to a lesson that specifies `autoReload` will always reload the preview. This is typically only needed if your server does not support HMR. |
| prepareCommands | | `Command[]` | β
| List of commands to execute sequentially. They are typically used to install dependencies or to run scripts. |
| mainCommand | | `Command` | β
| The main command to be executed. This command will run after the `prepareCommands`. |
A `Command` has the following shape:
```ts
string | [command: string, title: string] | { command: string, title: string }
```
The `title` is used as part of the boot screen (see [UI Structure](#ui-structure)).
A `Preview` has the following shape:
```ts
string | [port: number, title: string] | { port: number, title: string }
```
In most cases, metadata is inherited. For example, if you specify a `mainCommand` on a chapter without specifying it on any of its lessons, each lesson will use the `mainCommand` from its respective chapter. This extends to chapter and parts as well.