UNPKG

tutorialkit

Version:

Interactive tutorials powered by WebContainer API

150 lines (118 loc) β€’ 7.37 kB
# 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.