stackblitz / tutorialkit

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

Ability to include files from other lesson / template in the `Files` of the current lesson #393

Open noam-honig opened 4 weeks ago

noam-honig commented 4 weeks ago

Is your feature request related to a problem?

Often I have several lessons that coverthe same files. I want these files to appear in the lesson for context to the user - so the result is that I have mutiple files with the same name and same content duplicated among multiple lessons. Currently I copy them between each lesson - but then I change one of them and forget to update the rest and it becomes hard to maintain.

Describe the solution you'd like.

In the content.md in the front matter - allow to referene files from other lessons, and they'll be included here as well - something like:

---
type: lesson
title: Custom Filter
template: relations
focus: /frontend/Page.tsx
files:
  - ./previous-lesson/_files/shared/Order.ts
---

Describe alternatives you've considered.

Duplicating files - but that's hard to maintain

Additional context

No response

AriPerkkio commented 4 weeks ago

This sounds exactly as

Here's example usage of it

noam-honig commented 4 weeks ago

Hi @AriPerkkio thanks for pointing that out. I wanted to try it ( and document it) but couldn't get it to wrok.

Is it already released?

When I do:

---
type: lesson
title: Introduction
template:
  name: relations
  visibleFiles: ['/backend/index.ts']
focus: /shared/Customer.ts
---

I get an error

10:42:42 [watch] src/content/tutorial/4-concepts/6-sql-expression/1-introduction/content.md
10:42:43 [ERROR] [InvalidContentEntryFrontmatterError] tutorial → 4-concepts/6-sql-expression/1-introduction/content.md frontmatter does not match collection schema.
Did not match union:
  Hint:
    See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas.
  Error reference:
    https://docs.astro.build/en/reference/errors/invalid-content-entry-frontmatter-error/
  Stack trace:
    at getEntryDataAndImages (file:///C:/repos/radweb/docs/interactive/node_modules/astro/dist/content/utils.js:137:26)
    [...] See full stack trace in the browser, or rerun with --verbose.

Here are the versions I'm using:

  "dependencies": {
    "@iconify-json/ri": "^1.2.2",
    "@tutorialkit/react": "1.1.1",
    "react": "^18.3.1",
    "react-dom": "^18.3.1"
  },
  "devDependencies": {
    "@astrojs/check": "^0.7.0",
    "@astrojs/react": "^3.6.0",
    "@tutorialkit/astro": "1.1.1",
    "@tutorialkit/theme": "1.1.1",
    "@tutorialkit/types": "1.1.1",
    "@types/node": "^20.14.6",
    "@types/react": "^18.3.3",
    "astro": "^4.15.0",
    "prettier-plugin-astro": "^0.14.1",
    "typescript": "^5.4.5"
  }
AriPerkkio commented 4 weeks ago

It's not yet finished or released. We'll need to discuss this with the team a bit more before we know what kind of API we want for it.

This discussion is not yet resolved: https://github.com/stackblitz/tutorialkit/pull/165#discussion_r1734253274