stackblitz / tutorialkit

TutorialKit by StackBlitz - Create interactive tutorials powered by the WebContainer API
https://tutorialkit.dev
MIT License
503 stars 48 forks source link

feat(astro): support lessons without parts or chapters #374

Closed AriPerkkio closed 1 week ago

AriPerkkio commented 1 month ago

Adds support for defining lessons without chapters or parts.

src/content/tutorial
│
├── meta.md # Tutorial metadata
│
└── lesson-1 # Lesson in root! No part or chapter.
   ├── content.md
   ├── _files
   └── _solution
src/content/tutorial
│
├── meta.md # Tutorial metadata
│
└── part-1
    └── lesson-1 # Lesson in part! No chapter.
        ├── content.md
        ├── _files
        └── _solution

Custom order can be defined using lessons in metadata:

---
type: 'tutorial'
lessons: ['lesson-one', 'lesson-two']
---
---
type: 'part'
lessons: ['lesson-one', 'lesson-two']
---

Mixing structures is not supported and an error is thrown when these are not followed:

In practice:

src/content/tutorial
├── meta.md # Tutorial
├── lesson-1 # Lesson
└── part-1 # Part

> Error: Cannot mix lessons and parts in a tutorial. Either remove the parts or move root level lessons into a part.

src/content/tutorial
├── meta.md # Tutorial
└── part-1 # Part
    ├── lesson-1 # Lesson
    └── chapter-1 # Chapter

> Error: Cannot mix lessons and chapters in a part. Either remove the chapter from 1-part or move the lessons into a chapter.

However you can have multiple part's, where some contain just chapter's and some contain just lesson's:

src/content/tutorial
├── meta.md # Tutorial
│
├── part-1 # Part with lessons
│   └── lesson-1 # Lesson
│
└── part-2 # Part with chapters
    └── chapter-1 # Chapter

tk-mixed-hierarchy.webm

stackblitz[bot] commented 1 month ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

AriPerkkio commented 1 month ago

/pkg-pr-new

AriPerkkio commented 1 month ago

/pkg-pr-new

AriPerkkio commented 1 month ago

/pkg-pr-new

⚡️ Your npm packages are published. @tutorialkit/astro: npm i https://pkg.pr.new/@tutorialkit/astro@b57a764 @tutorialkit/runtime: npm i https://pkg.pr.new/@tutorialkit/runtime@b57a764 @tutorialkit/react: npm i https://pkg.pr.new/@tutorialkit/react@b57a764 @tutorialkit/theme: npm i https://pkg.pr.new/@tutorialkit/theme@b57a764 @tutorialkit/types: npm i https://pkg.pr.new/@tutorialkit/types@b57a764

AriPerkkio commented 1 month ago

/pkg-pr-new

⚡️ Your npm packages are published. @tutorialkit/astro: npm i https://pkg.pr.new/@tutorialkit/astro@431145a @tutorialkit/react: npm i https://pkg.pr.new/@tutorialkit/react@431145a @tutorialkit/runtime: npm i https://pkg.pr.new/@tutorialkit/runtime@431145a @tutorialkit/theme: npm i https://pkg.pr.new/@tutorialkit/theme@431145a @tutorialkit/types: npm i https://pkg.pr.new/@tutorialkit/types@431145a

AriPerkkio commented 1 week ago

Thanks for review @Nemikolh, let's get this merged! 💯