stackblitz / tutorialkit

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

Option to use lesson solution as a template for next lesson #349

Open noam-honig opened 1 month ago

noam-honig commented 1 month ago

Is your feature request related to a problem?

I have step by step tutorial, where the next step in many cases rely on the previous step (lesson) I find my self creating templates that are copies of the solution of the previous step - and though that this could be simplified.

I'm using the .tk-config.json to only put changed files in that template - but still that template is a copy of the solution of the previous step

Describe the solution you'd like.

I wish I could refer to a lesson in the template: option of a lesson

Describe alternatives you've considered.

Create a lot of templates - less fun

Additional context

No response

Nemikolh commented 1 month ago

Hey @noam-honig! This is a very good idea! I like it!

Regarding how you refer to the previous lesson as a template, I'm thinking we could use a path like ../prev-lesson-folder.

What do you think?

noam-honig commented 1 month ago

@Nemikolh Sounds prefer.

A bit unrelated question - I hope it's ok, I'm having a wierd behavior around cookies with stackblitz, using cookie-session. I can easily reproduce it in this tutorial or a stackblitz project version of it, but reproducing it stand alone would take a long time. Is this something that's of interest - if so I'll spend the time

noam-honig commented 1 month ago

@Nemikolh I mean sounds perfect :)

Nemikolh commented 1 month ago

Yes! That's definitely of interest! If you can share the stackblitz project, we'll have a look. :+1:

noam-honig commented 1 month ago

Yes! That's definitely of interest! If you can share the stackblitz project, we'll have a look. 👍

@Nemikolh thank you for that - i've been suffering from it for a while.

I created a small reproduction of the issue, you can find it at: https://stackblitz.com/edit/stackblitz-starters-m9nszw?file=index.js

You'll see how saving the user alex in the session works, and saving the user steve does not.

Initially I said that I don't like steve and that's ok - but I saw that other things break the cookie as well This only happens in stackblitz - and I can see in the cookies section of the browser, that it seems that the result cookie is tempred with and breaks down - you can see that there is a weird date key, and that the signature is cleared for the values that don't work.

Value with alex: image

Value with steve: image

Let me know if that's ok

noam-honig commented 1 month ago

Hey @noam-honig! This is a very good idea! I like it!

Regarding how you refer to the previous lesson as a template, I'm thinking we could use a path like ../prev-lesson-folder.

What do you think?

Hi, @Nemikolh I think that this is a great idea - is there a timeline for it?

Nemikolh commented 1 month ago

First, thanks a lot for the repro! This is a really odd bug. I've added it to our internal tracker for WebContainer. We will let you know when we have a fix :+1:

I think that this is a great idea - is there a timeline for it?

I'm currently pretty busy with bolt and I'm not sure about @AriPerkkio. However if you want to take a stab at it, PRs are welcome!

AriPerkkio commented 1 month ago

I'm thinking we could use a path like ../prev-lesson-folder

Where would this path be used? In .tk-config.json that is put in lesson's _files or _solution?

Describe the solution you'd like.

I wish I could refer to a lesson in the template: option of a lesson

This is also pretty much same that https://github.com/stackblitz/tutorialkit/pull/165 provides. A way to create re-usable files that are shown in lesson's editor.

noam-honig commented 1 month ago

I'm thinking we could use a path like ../prev-lesson-folder

Where would this path be used? In .tk-config.json that is put in lesson's _files or _solution?

Describe the solution you'd like.

I wish I could refer to a lesson in the template: option of a lesson

This is also pretty much same that #165 provides. A way to create re-usable files that are shown in lesson's editor.

I think it differs from #165 since I don't want to show these files in the lesson - I want these files to actually be like template files - hidden - and I want to avoid the need to duplicate files - and maintain so many duplications.

Today I find myself with templates that are called "solution_lession_x" that I use in lesson x+1

As for the "where would this path be used?" I would use it in the template field in the lesson front-matter.

The entire idea is not to duplicate files, and use them as templates in the next lesson.

For example - conisder I'm building a full stack app - in the first lesson I've built the sign in mechanism - in the second lesson I do things with signed in users, I want the solution of the lesson about the sign in mechanizm to be used as the template for the lesson about doing things with them - without duplicating the files, and without showing them in the lesson editor (unless I specifically put them there)

just like a template

Sorry for the long text, I'm not sure I'm expressing myself clearly so I decided to elaborate