Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to set html css tutorial ; want to disply HTMl file in preview tab #431

Answered by AriPerkkio
xkeshav asked this question in Q&A
Discussion options

Describe the bug

I want to create CSS tutorials and added

  • A file under tutorial/1-basics/1-introduction/1-welcome/__files/basic.html

but in preview tab it keep loading the default template which have Viteand everytim when I refresh i fo npm install

so my questions are

  • How to preview my html file; , do I need to write same html under templates folder or can I add a buton on current default template to link the page with current lesson?
  • How to stop npm install and npm start on every page refresh
    • also in /content/tutorial/1-basics/1-introduction/1-welcome/content.md , there is focus property which is not metioned anywhere, how to use?

Link to a StackBlitz project which shows the error

No response

Steps to reproduce

  1. install the app
  2. add fils _files/basic.html

Expected behavior

In preview tab ; it must show my HTML file and do not install on every refresh

here is the repo link : https://github.com/xkeshav/tutorial-kit

Screenshots

image

this is how it looks when loadedpage load

image

Platform

  • TutorialKit version: 1.3.1
  • OS: Ubuntu 24.04
  • Browser: Chrome
  • Version: [e.g. 91.1]

Additional context

No response

You must be logged in to vote
  1. Add the style in template. All template files that are not overwritten by _files or _solution are used by default.
  2. I'm not sure what this means.
  3. A single lesson can have single solution, so showing multiple different solutions requires separate lessons.

also curious where does this template/default/index.html visible ?

It will be visible if you don't provide _files/index.html. Template files are used by default, _files overwrite them. _solution is used when Solve-button is clicked.

Replies: 3 comments 6 replies

Comment options

Hey @xkeshav,

How to preview my html file; , do I need to write same html under templates folder or can I add a buton on current default template to link the page with current lesson?

In the template you'll need to create a Node project that serves the html file. In _files and _solution you can add files that then overwrite the template files. See https://tutorialkit.dev/guides/creating-content/.

How to stop npm install and npm start on every page refresh

On page refresh you need to run these commands in order to have dependencies installed and server running. However you don't need to refresh page when moving between tutorial's lessons.

alos in /content/tutorial/1-basics/1-introduction/1-welcome/content.md , there is focus property which is not metioned anywhere, how to use?

It's mentioned here on the documentation: https://tutorialkit.dev/reference/configuration/#focus

Have you checked https://demo.tutorialkit.dev? Its sources are available at https://github.com/stackblitz/tutorialkit/tree/main/docs/demo. You could use those as reference.

You must be logged in to vote
2 replies
Comment options

Thanks, will look into demo

I have seen that in template/default , thete is filename counter.ts

So do I need to create each file twice on in template and other under tutorials chapters?

Why am I asking this

I want to show one html without applying css and when user click on solve button then it should reflect those changes in preview too

Comment options

Here's an example, check the template and lesson files: https://stackblitz.com/~/edit/node-snebqbgq

So do I need to create each file twice on in template and other under tutorials chapters?

The files that you want to overwrite from template need to be created in _files and _solution.

Comment options

Thanks. this works great. followup questions. here is forked stackblitz link

  1. to add common style , can I use one css file which server both _files and _solution ?
  2. we have addec complete HTML sementics in each page;(i.e. <head> <body> ) can we make it common and render only the body part in the files?
  3. if we have multiple solution for a same problem statment ( like using various css approach); then how to show all solution or just create multiple files and their css and import ( like we do ussually )
  4. also curious where does this template/default/index.html visible ?
You must be logged in to vote
3 replies
Comment options

  1. Add the style in template. All template files that are not overwritten by _files or _solution are used by default.
  2. I'm not sure what this means.
  3. A single lesson can have single solution, so showing multiple different solutions requires separate lessons.

also curious where does this template/default/index.html visible ?

It will be visible if you don't provide _files/index.html. Template files are used by default, _files overwrite them. _solution is used when Solve-button is clicked.

Answer selected by xkeshav
Comment options

complete HTML in each page means every page we have written whole HTML tags <!doctype><head><meta>and then <body>
so my question is can we have common template which can cater for all other files. ( might be talking contradicting)
also, can we keep have package.json for each tutorials, I want one with react and other with angular or htmx

Comment options

my question is can we have common template which can cater for all other files

That's not possible with plain HTML, you'll need a framework that can handle importing multiple HTML files. How would you build that outside TutorialKit when using NodeJS? Do the same here and place the code in template.

can we keep have package.json for each tutorials, I want one with react and other with angular or htmx

Yes, you can have separate package.json's for lessons. You can override template/default/package.json by having _files/package.json. Alternatively you could have template/default, tempate/react, tempalte/angular and template/htmx. Here's an example of tutorial with multiple templates: https://github.com/AriPerkkio/tutorial-vite-plugin/tree/main/src/templates.

Comment options

Thank you very much for helping me quickly.
if we write anything in meta.md files under tutorials, below the frontmatters then it will not visible anywhere on page ; these files are only have limited scope. right?

for eg.

/ src/content/tutorial/meta.md

---
type: tutorial
template: basic-html
mainCommand: ['npm run start', 'Starting http server']
prepareCommands:
 - ['npm install', 'Installing dependencies']
---
<h1>Welcome to Popover Tutorial</h1>

or in

/src/content/tutorial/basics/meta.md

---
type: part
title: Basics
---
## This is basic part
You must be logged in to vote
1 reply
Comment options

Content from meta.md is not visible in tutorials. Only content.md from lessons is visible. https://tutorialkit.dev/guides/creating-content/#a-lesson-content-file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Question related to TutorialKit that doesn't require changes in codebase.
Converted from issue

This discussion was converted from issue #430 on December 31, 2024 07:48.

AltStyle によって変換されたページ (->オリジナル) /