@tutorialkit-rb/astro 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,9 +12,10 @@ import { hasWorkspace } from '../utils/workspace';
12
12
  interface Props {
13
13
  lesson: Lesson<AstroComponentFactory>;
14
14
  navList: NavList;
15
+ showNav?: boolean;
15
16
  }
16
17
 
17
- const { lesson, navList } = Astro.props;
18
+ const { lesson, navList, showNav = true } = Astro.props;
18
19
 
19
20
  const showWorkspacePanel = hasWorkspace(lesson);
20
21
  ---
@@ -31,7 +32,7 @@ const showWorkspacePanel = hasWorkspace(lesson);
31
32
  class="h-full flex flex-col transition-theme bg-tk-elements-app-backgroundColor text-tk-elements-app-textColor"
32
33
  slot="a"
33
34
  >
34
- <Nav client:load lesson={lesson} navList={navList} />
35
+ {showNav && <Nav client:load lesson={lesson} navList={navList} />}
35
36
  <TutorialContent lesson={lesson} />
36
37
  </div>
37
38
  <div
@@ -37,6 +37,7 @@ const canonicalUrl = Astro.site ? new URL(Astro.url.pathname, Astro.site).toStri
37
37
  <ViewTransitions />
38
38
  <script is:inline>
39
39
  setTutorialKitTheme();
40
+ setTutorialKitEmbed();
40
41
 
41
42
  function setTutorialKitTheme() {
42
43
  let theme = localStorage.getItem('tk_theme');
@@ -47,12 +48,19 @@ const canonicalUrl = Astro.site ? new URL(Astro.url.pathname, Astro.site).toStri
47
48
 
48
49
  document.querySelector('html')?.setAttribute('data-theme', theme);
49
50
  }
51
+
52
+ function setTutorialKitEmbed() {
53
+ if (new URLSearchParams(window.location.search).get('embed') === 'true') {
54
+ document.querySelector('html')?.setAttribute('data-embed', 'true');
55
+ }
56
+ }
50
57
  </script>
51
58
  <script>
52
59
  import { swapFunctions as builtInSwap } from 'astro:transitions/client';
53
60
 
54
61
  declare global {
55
62
  function setTutorialKitTheme(): void;
63
+ function setTutorialKitEmbed(): void;
56
64
  }
57
65
 
58
66
  document.addEventListener('astro:before-swap', (event) => {
@@ -63,6 +71,7 @@ const canonicalUrl = Astro.site ? new URL(Astro.url.pathname, Astro.site).toStri
63
71
  builtInSwap.swapRootAttributes(newDocument);
64
72
 
65
73
  setTutorialKitTheme();
74
+ setTutorialKitEmbed();
66
75
 
67
76
  /**
68
77
  * Keep the dynamically injected style sheet from Codemirror on all transitions.
@@ -15,6 +15,12 @@ export async function getStaticPaths() {
15
15
  type Props = InferGetStaticPropsType<typeof getStaticPaths>;
16
16
 
17
17
  const { lesson, logoLink, navList, title } = Astro.props as Props;
18
+
19
+ // Embed mode configuration
20
+ const embedMode = Astro.url.searchParams.get('embed') === 'true';
21
+ const showTopBar = !embedMode;
22
+ const showNav = !embedMode;
23
+
18
24
  const meta = lesson.data?.meta ?? {};
19
25
 
20
26
  // use lesson's default title and a default description for SEO metadata
@@ -28,12 +34,14 @@ meta.description ??= 'A TutorialKit interactive lesson';
28
34
  <div id="previews-container" style="display: none;"></div>
29
35
 
30
36
  <main class="max-w-full flex flex-col h-full overflow-hidden" data-swap-root>
31
- <TopBarWrapper
32
- logoLink={logoLink ?? '/'}
33
- openInStackBlitz={lesson.data.openInStackBlitz}
34
- downloadAsZip={lesson.data.downloadAsZip}
35
- />
36
-
37
- <MainContainer lesson={lesson} navList={navList} />
37
+ {showTopBar && (
38
+ <TopBarWrapper
39
+ logoLink={logoLink ?? '/'}
40
+ openInStackBlitz={lesson.data.openInStackBlitz}
41
+ downloadAsZip={lesson.data.downloadAsZip}
42
+ />
43
+ )}
44
+
45
+ <MainContainer lesson={lesson} navList={navList} showNav={showNav} />
38
46
  </main>
39
47
  </Layout>
@@ -9,3 +9,12 @@ body {
9
9
  font-style: normal;
10
10
  font-variation-settings: 'slnt' 0;
11
11
  }
12
+
13
+ /* Embed mode: hide top bar and navigation */
14
+ html[data-embed='true'] main[data-swap-root] > nav {
15
+ display: none;
16
+ }
17
+
18
+ html[data-embed='true'] main[data-swap-root] header {
19
+ display: none;
20
+ }
@@ -87,6 +87,7 @@ export async function getTutorial(): Promise<Tutorial> {
87
87
  ...squash(sources, [
88
88
  'mainCommand',
89
89
  'prepareCommands',
90
+ 'terminalBlockingPrepareCommandsCount',
90
91
  'previews',
91
92
  'autoReload',
92
93
  'template',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tutorialkit-rb/astro",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "TutorialKit integration for Astro (https://astro.build)",
5
5
  "author": "StackBlitz Inc.",
6
6
  "type": "module",
@@ -54,10 +54,10 @@
54
54
  "unist-util-visit": "^5.0.0",
55
55
  "unocss": "^0.59.4",
56
56
  "zod": "3.23.8",
57
- "@tutorialkit-rb/runtime": "0.1.5",
58
- "@tutorialkit-rb/types": "0.1.5",
59
- "@tutorialkit-rb/react": "0.1.5",
60
- "@tutorialkit-rb/theme": "0.1.5"
57
+ "@tutorialkit-rb/react": "0.1.7",
58
+ "@tutorialkit-rb/runtime": "0.1.7",
59
+ "@tutorialkit-rb/theme": "0.1.7",
60
+ "@tutorialkit-rb/types": "0.1.7"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/mdast": "^4.0.4",
@@ -67,7 +67,7 @@
67
67
  "typescript": "^5.4.5",
68
68
  "vite-plugin-inspect": "0.8.4",
69
69
  "vitest": "^3.0.5",
70
- "@tutorialkit-rb/types": "0.1.5"
70
+ "@tutorialkit-rb/types": "0.1.7"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "astro": "^4.15.0"