playwright-director 0.5.0 → 0.6.0
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.
- package/README.md +74 -10
- package/dist/Tutorial.d.ts.map +1 -1
- package/dist/Tutorial.js +1 -1
- package/dist/Tutorial.js.map +1 -1
- package/dist/init.js +11 -1
- package/dist/init.js.map +1 -1
- package/dist/site/build-site.d.ts +6 -0
- package/dist/site/build-site.d.ts.map +1 -1
- package/dist/site/build-site.js +13 -2
- package/dist/site/build-site.js.map +1 -1
- package/dist/site/embed.d.ts +9 -0
- package/dist/site/embed.d.ts.map +1 -1
- package/dist/site/embed.js +7 -3
- package/dist/site/embed.js.map +1 -1
- package/dist/site/generate-manifest.d.ts +2 -0
- package/dist/site/generate-manifest.d.ts.map +1 -1
- package/dist/site/generate-manifest.js +57 -16
- package/dist/site/generate-manifest.js.map +1 -1
- package/dist/site/scaffold.d.ts +6 -0
- package/dist/site/scaffold.d.ts.map +1 -1
- package/dist/site/scaffold.js +54 -8
- package/dist/site/scaffold.js.map +1 -1
- package/dist/site/scan-tutorials.d.ts +2 -0
- package/dist/site/scan-tutorials.d.ts.map +1 -1
- package/dist/site/scan-tutorials.js +3 -1
- package/dist/site/scan-tutorials.js.map +1 -1
- package/dist/site/seo.d.ts +22 -0
- package/dist/site/seo.d.ts.map +1 -0
- package/dist/site/seo.js +91 -0
- package/dist/site/seo.js.map +1 -0
- package/dist/site/strings.d.ts +19 -0
- package/dist/site/strings.d.ts.map +1 -1
- package/dist/site/strings.js +57 -3
- package/dist/site/strings.js.map +1 -1
- package/dist/site/tokens.d.ts +28 -0
- package/dist/site/tokens.d.ts.map +1 -0
- package/dist/site/tokens.js +38 -0
- package/dist/site/tokens.js.map +1 -0
- package/dist/site/types.d.ts +57 -12
- package/dist/site/types.d.ts.map +1 -1
- package/dist/timeline.d.ts +7 -1
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +5 -1
- package/dist/timeline.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/schemas/embed-v1.schema.json +5 -0
- package/skills/tutorialize/SKILL.md +7 -2
- package/skills/tutorialize/agent.md +4 -0
- package/skills/tutorialize/references/api.md +1 -0
- package/skills/tutorialize/references/site.md +158 -0
- package/templates/site/public/widget.js +16 -11
- package/templates/site/src/components/Emphasis.astro +8 -0
- package/templates/site/src/components/HomeLangs.astro +20 -0
- package/templates/site/src/components/LangSwitch.astro +20 -0
- package/templates/site/src/components/Lightbox.astro +50 -0
- package/templates/site/src/components/PrevNext.astro +40 -0
- package/templates/site/src/components/Seo.astro +42 -0
- package/templates/site/src/components/StepGuide.astro +115 -0
- package/templates/site/src/components/StepStrip.astro +33 -0
- package/templates/site/src/components/ThemeSwitcher.astro +22 -0
- package/templates/site/src/components/VariantFilter.astro +36 -0
- package/templates/site/src/components/VideoCard.astro +1 -103
- package/templates/site/src/components/VideoLinks.astro +19 -0
- package/templates/site/src/components/VideoModal.astro +66 -153
- package/templates/site/src/components/VideoPlayer.astro +43 -0
- package/templates/site/src/i18n.ts +8 -3
- package/templates/site/src/layouts/Shell.astro +46 -0
- package/templates/site/src/lib/filter.ts +24 -0
- package/templates/site/src/lib/site.ts +127 -0
- package/templates/site/src/pages/[lang]/index.astro +6 -6
- package/templates/site/src/pages/[slug].astro +5 -850
- package/templates/site/src/pages/index.astro +2 -2
- package/templates/site/src/styles/components.css +919 -0
- package/templates/site/src/styles/user.css +1 -0
- package/templates/themes/academy/CourseNav.astro +56 -0
- package/templates/themes/academy/Home.astro +139 -0
- package/templates/themes/academy/Layout.astro +48 -0
- package/templates/themes/academy/VideoPage.astro +75 -0
- package/templates/themes/academy/theme.css +979 -0
- package/templates/themes/classic/Home.astro +58 -0
- package/templates/themes/classic/Layout.astro +46 -0
- package/templates/themes/classic/VideoPage.astro +47 -0
- package/templates/themes/classic/theme.css +289 -0
- package/templates/site/src/components/TutorialsHome.astro +0 -169
- package/templates/site/src/layouts/Base.astro +0 -61
- package/templates/site/src/styles/tutorials.css +0 -303
|
@@ -18,7 +18,7 @@ const { id, title, duration, videoUrl, steps = [], href, variant, lang } = Astro
|
|
|
18
18
|
const rtl = RTL_LANGS.includes(lang ?? '');
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
<div class="video-card" data-video-url={videoUrl} data-video-id={id} data-variant={variant ?? ''} data-lang={lang ?? ''} lang={lang} dir={rtl ? 'rtl' : undefined}>
|
|
21
|
+
<div class="video-card" data-quickview data-video-url={videoUrl} data-video-id={id} data-variant={variant ?? ''} data-lang={lang ?? ''} lang={lang} dir={rtl ? 'rtl' : undefined}>
|
|
22
22
|
<div class="video-thumbnail">
|
|
23
23
|
{steps.length > 0 ? (
|
|
24
24
|
<div class="step-carousel">
|
|
@@ -59,108 +59,6 @@ const rtl = RTL_LANGS.includes(lang ?? '');
|
|
|
59
59
|
</div>
|
|
60
60
|
</div>
|
|
61
61
|
|
|
62
|
-
<style>
|
|
63
|
-
.video-variant {
|
|
64
|
-
font-size: 0.75rem;
|
|
65
|
-
color: var(--color-text-muted, #666);
|
|
66
|
-
border: 1px solid var(--color-border, #ddd);
|
|
67
|
-
border-radius: 999px;
|
|
68
|
-
padding: 0.1rem 0.5rem;
|
|
69
|
-
text-transform: capitalize;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.card-page-link {
|
|
73
|
-
margin-left: auto;
|
|
74
|
-
font-size: 0.9rem;
|
|
75
|
-
color: var(--color-text-muted);
|
|
76
|
-
text-decoration: none;
|
|
77
|
-
transition: color 0.2s;
|
|
78
|
-
flex-shrink: 0;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.card-page-link:hover {
|
|
82
|
-
color: var(--color-primary);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.placeholder-thumb {
|
|
86
|
-
width: 100%;
|
|
87
|
-
height: 100%;
|
|
88
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.step-carousel {
|
|
92
|
-
position: absolute;
|
|
93
|
-
inset: 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.step-img {
|
|
97
|
-
position: absolute;
|
|
98
|
-
inset: 0;
|
|
99
|
-
width: 100%;
|
|
100
|
-
height: 100%;
|
|
101
|
-
object-fit: cover;
|
|
102
|
-
opacity: 0;
|
|
103
|
-
transition: opacity 0.3s;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.step-img.active {
|
|
107
|
-
opacity: 1;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.step-prev,
|
|
111
|
-
.step-next {
|
|
112
|
-
position: absolute;
|
|
113
|
-
top: 50%;
|
|
114
|
-
transform: translateY(-50%);
|
|
115
|
-
background: rgba(0, 0, 0, 0.5);
|
|
116
|
-
color: white;
|
|
117
|
-
border: none;
|
|
118
|
-
width: 28px;
|
|
119
|
-
height: 28px;
|
|
120
|
-
border-radius: 50%;
|
|
121
|
-
font-size: 1.2rem;
|
|
122
|
-
line-height: 1;
|
|
123
|
-
cursor: pointer;
|
|
124
|
-
display: flex;
|
|
125
|
-
align-items: center;
|
|
126
|
-
justify-content: center;
|
|
127
|
-
opacity: 0;
|
|
128
|
-
transition: opacity 0.2s;
|
|
129
|
-
z-index: 2;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.step-prev { left: 6px; }
|
|
133
|
-
.step-next { right: 6px; }
|
|
134
|
-
|
|
135
|
-
.video-card:hover .step-prev,
|
|
136
|
-
.video-card:hover .step-next {
|
|
137
|
-
opacity: 1;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.step-dots {
|
|
141
|
-
position: absolute;
|
|
142
|
-
bottom: 6px;
|
|
143
|
-
left: 50%;
|
|
144
|
-
transform: translateX(-50%);
|
|
145
|
-
display: flex;
|
|
146
|
-
gap: 4px;
|
|
147
|
-
z-index: 2;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.step-dot {
|
|
151
|
-
width: 5px;
|
|
152
|
-
height: 5px;
|
|
153
|
-
border-radius: 50%;
|
|
154
|
-
background: rgba(255, 255, 255, 0.4);
|
|
155
|
-
cursor: pointer;
|
|
156
|
-
transition: background 0.2s;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.step-dot.active {
|
|
160
|
-
background: white;
|
|
161
|
-
}
|
|
162
|
-
</style>
|
|
163
|
-
|
|
164
62
|
<script>
|
|
165
63
|
document.querySelectorAll<HTMLElement>('.step-carousel').forEach(carousel => {
|
|
166
64
|
const imgs = carousel.querySelectorAll<HTMLElement>('.step-img');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
// "Open in the app" / "Read the documentation" buttons of a video page (manifest `links`, already absolute).
|
|
3
|
+
import { t } from '../i18n';
|
|
4
|
+
import type { Video } from '../lib/site';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
video: Video;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { video } = Astro.props;
|
|
11
|
+
const { app, docs } = (video.links ?? {}) as { app?: string; docs?: string };
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
{(app || docs) && (
|
|
15
|
+
<div class="video-links">
|
|
16
|
+
{app && <a class="video-link video-link-app" href={app}>{t(video.lang, 'openInApp')} <span aria-hidden="true">↗</span></a>}
|
|
17
|
+
{docs && <a class="video-link video-link-docs" href={docs}>{t(video.lang, 'readDocs')} <span aria-hidden="true">↗</span></a>}
|
|
18
|
+
</div>
|
|
19
|
+
)}
|
|
@@ -1,171 +1,84 @@
|
|
|
1
1
|
---
|
|
2
|
-
//
|
|
3
|
-
|
|
2
|
+
// Quick-view player for home cards (`.video-card[data-video-url]`): native modal <dialog>
|
|
3
|
+
// (page inert, Esc closes, focus returns to the card), ←/→ and buttons walk the visible
|
|
4
|
+
// cards of the same section, the title bar links to the full tutorial page.
|
|
5
|
+
// Only a click inside the card's `[data-quickview]` zone opens it (Classic: the whole card; Académie: the
|
|
6
|
+
// thumbnail — the text follows the link). A card link keeps working with a modifier key and without JS.
|
|
7
|
+
import { t } from '../i18n';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
lang?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { lang: L } = Astro.props;
|
|
4
14
|
---
|
|
5
15
|
|
|
6
|
-
<
|
|
7
|
-
<button class="video-modal-close" aria-label={t(
|
|
16
|
+
<dialog id="video-modal" class="video-modal" aria-labelledby="video-title">
|
|
17
|
+
<button class="video-modal-close" aria-label={t(L, 'close')}>×</button>
|
|
8
18
|
<div class="video-container">
|
|
9
|
-
<button class="video-nav video-nav-prev" aria-label={t(
|
|
10
|
-
<video controls id="modal-video">
|
|
11
|
-
|
|
12
|
-
</video>
|
|
13
|
-
<button class="video-nav video-nav-next" aria-label={t(siteLang, 'next')} style="display: none;">›</button>
|
|
19
|
+
<button class="video-nav video-nav-prev" aria-label={t(L, 'previous')}>‹</button>
|
|
20
|
+
<video controls id="modal-video"></video>
|
|
21
|
+
<button class="video-nav video-nav-next" aria-label={t(L, 'next')}>›</button>
|
|
14
22
|
</div>
|
|
15
23
|
<div class="video-title-bar">
|
|
16
|
-
<
|
|
24
|
+
<a id="video-title" href=""></a>
|
|
17
25
|
<span id="video-counter"></span>
|
|
18
26
|
</div>
|
|
19
|
-
</
|
|
20
|
-
|
|
21
|
-
<style>
|
|
22
|
-
.video-container {
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
gap: 1rem;
|
|
26
|
-
max-width: 100%;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.video-nav {
|
|
30
|
-
background: rgba(255, 255, 255, 0.9);
|
|
31
|
-
border: none;
|
|
32
|
-
width: 50px;
|
|
33
|
-
height: 50px;
|
|
34
|
-
border-radius: 50%;
|
|
35
|
-
font-size: 2rem;
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
transition: all 0.2s;
|
|
38
|
-
flex-shrink: 0;
|
|
39
|
-
display: flex;
|
|
40
|
-
align-items: center;
|
|
41
|
-
justify-content: center;
|
|
42
|
-
line-height: 1;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.video-nav:hover {
|
|
46
|
-
background: white;
|
|
47
|
-
transform: scale(1.1);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.video-nav:disabled {
|
|
51
|
-
opacity: 0.3;
|
|
52
|
-
cursor: not-allowed;
|
|
53
|
-
transform: none;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.video-title-bar {
|
|
57
|
-
display: flex;
|
|
58
|
-
justify-content: space-between;
|
|
59
|
-
align-items: center;
|
|
60
|
-
width: 100%;
|
|
61
|
-
max-width: 900px;
|
|
62
|
-
margin-top: 1rem;
|
|
63
|
-
padding: 0 60px;
|
|
64
|
-
color: white;
|
|
65
|
-
font-size: 0.9rem;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
#video-title {
|
|
69
|
-
font-weight: 500;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
#video-counter {
|
|
73
|
-
opacity: 0.7;
|
|
74
|
-
}
|
|
75
|
-
</style>
|
|
27
|
+
</dialog>
|
|
76
28
|
|
|
77
29
|
<script>
|
|
78
|
-
document.
|
|
79
|
-
|
|
80
|
-
const video =
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (videoUrl && videoSource && video) {
|
|
101
|
-
videoSource.src = videoUrl;
|
|
102
|
-
video.load();
|
|
103
|
-
video.play();
|
|
104
|
-
|
|
105
|
-
// Update title and counter
|
|
106
|
-
if (titleEl) titleEl.textContent = title;
|
|
107
|
-
if (counterEl) counterEl.textContent = `${index + 1} / ${cards.length}`;
|
|
108
|
-
|
|
109
|
-
// Update nav buttons
|
|
110
|
-
if (prevBtn) {
|
|
111
|
-
prevBtn.style.display = 'flex';
|
|
112
|
-
prevBtn.disabled = index === 0;
|
|
113
|
-
}
|
|
114
|
-
if (nextBtn) {
|
|
115
|
-
nextBtn.style.display = 'flex';
|
|
116
|
-
nextBtn.disabled = index === cards.length - 1;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
30
|
+
const modal = document.getElementById('video-modal') as HTMLDialogElement | null;
|
|
31
|
+
if (modal) {
|
|
32
|
+
const video = modal.querySelector('video')!;
|
|
33
|
+
const prevBtn = modal.querySelector<HTMLButtonElement>('.video-nav-prev')!;
|
|
34
|
+
const nextBtn = modal.querySelector<HTMLButtonElement>('.video-nav-next')!;
|
|
35
|
+
const titleEl = modal.querySelector<HTMLAnchorElement>('#video-title')!;
|
|
36
|
+
const counterEl = modal.querySelector<HTMLElement>('#video-counter')!;
|
|
37
|
+
let list: HTMLElement[] = [];
|
|
38
|
+
let index = 0;
|
|
39
|
+
|
|
40
|
+
const play = (i: number) => {
|
|
41
|
+
if (i < 0 || i >= list.length) return;
|
|
42
|
+
index = i;
|
|
43
|
+
const card = list[i];
|
|
44
|
+
video.src = card.dataset.videoUrl!;
|
|
45
|
+
video.play().catch(() => {});
|
|
46
|
+
titleEl.textContent = card.querySelector('.video-title')?.textContent?.trim() || '';
|
|
47
|
+
titleEl.href = card.dataset.href || card.querySelector<HTMLAnchorElement>('a[href]')?.href || '';
|
|
48
|
+
counterEl.textContent = `${i + 1} / ${list.length}`;
|
|
49
|
+
prevBtn.disabled = i === 0;
|
|
50
|
+
nextBtn.disabled = i === list.length - 1;
|
|
119
51
|
};
|
|
120
52
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
card.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
53
|
+
document.addEventListener('click', (e) => {
|
|
54
|
+
// Card controls that must not open the dialog stop propagation themselves
|
|
55
|
+
const card = (e.target as HTMLElement).closest('[data-quickview]')?.closest<HTMLElement>('.video-card[data-video-url]');
|
|
56
|
+
if (!card || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return;
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
const scope = card.closest('.category') ?? document;
|
|
59
|
+
list = [...scope.querySelectorAll<HTMLElement>('.video-card[data-video-url]')].filter((c) => !c.closest('[hidden]'));
|
|
60
|
+
modal.showModal();
|
|
61
|
+
play(list.indexOf(card));
|
|
129
62
|
});
|
|
130
63
|
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
playVideo(currentIndex - 1);
|
|
64
|
+
// Size the box to the picture (desktop, mobile-variant and portrait recordings differ)
|
|
65
|
+
video.addEventListener('loadedmetadata', () => {
|
|
66
|
+
if (video.videoHeight) modal.style.setProperty('--pd-video-ratio', String(video.videoWidth / video.videoHeight));
|
|
135
67
|
});
|
|
136
|
-
|
|
137
|
-
nextBtn
|
|
138
|
-
|
|
139
|
-
|
|
68
|
+
prevBtn.addEventListener('click', () => play(index - 1));
|
|
69
|
+
nextBtn.addEventListener('click', () => play(index + 1));
|
|
70
|
+
video.addEventListener('ended', () => play(index + 1));
|
|
71
|
+
modal.querySelector('.video-modal-close')!.addEventListener('click', () => modal.close());
|
|
72
|
+
// The dialog fills the screen: a click on it (not on its content) is a backdrop click
|
|
73
|
+
modal.addEventListener('click', (e) => {
|
|
74
|
+
if (e.target === modal) modal.close();
|
|
140
75
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
}
|
|
76
|
+
modal.addEventListener('keydown', (e) => {
|
|
77
|
+
if ((e.target as HTMLElement).tagName === 'VIDEO') return;
|
|
78
|
+
const rtl = document.dir === 'rtl';
|
|
79
|
+
if (e.key === 'ArrowLeft') play(index + (rtl ? 1 : -1));
|
|
80
|
+
if (e.key === 'ArrowRight') play(index + (rtl ? -1 : 1));
|
|
147
81
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const closeModal = () => {
|
|
151
|
-
if (modal && video) {
|
|
152
|
-
modal.style.display = 'none';
|
|
153
|
-
video.pause();
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
closeBtn?.addEventListener('click', closeModal);
|
|
158
|
-
modal?.addEventListener('click', (e) => {
|
|
159
|
-
if (e.target === modal) closeModal();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// Keyboard navigation
|
|
163
|
-
document.addEventListener('keydown', (e) => {
|
|
164
|
-
if (modal?.style.display !== 'flex') return;
|
|
165
|
-
|
|
166
|
-
if (e.key === 'Escape') closeModal();
|
|
167
|
-
if (e.key === 'ArrowLeft') playVideo(currentIndex - 1);
|
|
168
|
-
if (e.key === 'ArrowRight') playVideo(currentIndex + 1);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
82
|
+
modal.addEventListener('close', () => video.pause());
|
|
83
|
+
}
|
|
171
84
|
</script>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
// The tutorial video. Chapters anywhere on the page ([data-at] steps + .step-time buttons) seek it,
|
|
3
|
+
// the playing step gets aria-current="step", and `?t=<seconds>` starts playback there.
|
|
4
|
+
import { media, posterOf, type Video } from '../lib/site';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
video: Video;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { video } = Astro.props;
|
|
11
|
+
const poster = posterOf(video);
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<div class="video-player-wrap">
|
|
15
|
+
<video controls class="video-player" id="tutorial-video" poster={poster ? media(poster) : undefined}>
|
|
16
|
+
<source src={media(video.file)} type="video/webm" />
|
|
17
|
+
</video>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
// Seeking needs a host that answers HTTP Range requests.
|
|
22
|
+
const player = document.getElementById('tutorial-video') as HTMLVideoElement | null;
|
|
23
|
+
if (player) {
|
|
24
|
+
const chapters = [...document.querySelectorAll<HTMLElement>('[data-at].step-block, [data-at].step-card, [data-at].step-row')];
|
|
25
|
+
document.querySelectorAll<HTMLElement>('.step-time').forEach((btn) => {
|
|
26
|
+
btn.addEventListener('click', () => {
|
|
27
|
+
player.currentTime = Number(btn.dataset.at);
|
|
28
|
+
player.play().catch(() => {});
|
|
29
|
+
player.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
let current: HTMLElement | undefined;
|
|
33
|
+
player.addEventListener('timeupdate', () => {
|
|
34
|
+
const now = chapters.filter((c) => Number(c.dataset.at) <= player.currentTime + 0.25).pop();
|
|
35
|
+
if (now === current) return;
|
|
36
|
+
current?.removeAttribute('aria-current');
|
|
37
|
+
now?.setAttribute('aria-current', 'step');
|
|
38
|
+
current = now;
|
|
39
|
+
});
|
|
40
|
+
const start = Number(new URLSearchParams(location.search).get('t'));
|
|
41
|
+
if (start > 0) player.currentTime = start;
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
@@ -7,8 +7,13 @@ export const RTL_LANGS = ['ar', 'he', 'fa', 'ur'];
|
|
|
7
7
|
/** Language switcher labels, in their own language */
|
|
8
8
|
export const LANG_NAMES: Record<string, string> = { fr: 'Français', en: 'English', ar: 'العربية', es: 'Español', de: 'Deutsch' };
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* `t(lang, 'step', { n: 2 })` — primary subtag, falls back to English, then to the key.
|
|
12
|
+
* A numeric `n` selects a plural form `<key>_<category>` (`sectionStats_one`) when the dictionary has one.
|
|
13
|
+
*/
|
|
11
14
|
export function t(lang: string | undefined, key: string, vars: Record<string, string | number> = {}): string {
|
|
12
|
-
const
|
|
13
|
-
|
|
15
|
+
const code = (lang || siteLang).toLowerCase().split('-')[0];
|
|
16
|
+
const dict = strings[code] ?? strings.en ?? {};
|
|
17
|
+
const plural = typeof vars.n === 'number' ? dict[`${key}_${new Intl.PluralRules(code).select(vars.n)}`] : undefined;
|
|
18
|
+
return (plural ?? dict[key] ?? key).replace(/\{(\w+)\}/g, (m, name) => (name in vars ? String(vars[name]) : m));
|
|
14
19
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Document shell shared by every theme: <html lang dir>, <head> (SEO, fonts), and the stylesheet order
|
|
3
|
+
// components.css → theme/theme.css → user.css (config tokens + `css` file, written by scaffold).
|
|
4
|
+
import '../styles/components.css';
|
|
5
|
+
import '../theme/theme.css';
|
|
6
|
+
import '../styles/user.css';
|
|
7
|
+
import Seo, { type SeoProps } from '../components/Seo.astro';
|
|
8
|
+
import { config } from '../lib/site';
|
|
9
|
+
import { siteLang, RTL_LANGS } from '../i18n';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
title: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
/** Page language (a tutorial page uses its narration language) */
|
|
15
|
+
lang?: string;
|
|
16
|
+
seo?: SeoProps;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { title, seo } = Astro.props;
|
|
20
|
+
const description = Astro.props.description || config.title;
|
|
21
|
+
const lang = Astro.props.lang || siteLang;
|
|
22
|
+
const dir = RTL_LANGS.includes(lang) ? 'rtl' : 'ltr';
|
|
23
|
+
const fonts: string[] = config.googleFonts ?? [];
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
<!doctype html>
|
|
27
|
+
<html lang={lang} dir={dir}>
|
|
28
|
+
<head>
|
|
29
|
+
<meta charset="UTF-8" />
|
|
30
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
31
|
+
<meta name="description" content={description} />
|
|
32
|
+
<title>{title} | {config.title}</title>
|
|
33
|
+
<Seo title={title} description={description} lang={lang} {...seo} />
|
|
34
|
+
{fonts.length > 0 && (
|
|
35
|
+
<>
|
|
36
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
37
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
38
|
+
<link rel="stylesheet" href={`https://fonts.googleapis.com/css2?${fonts.map((f) => `family=${f.replace(/ /g, '+')}`).join('&')}&display=swap`} />
|
|
39
|
+
</>
|
|
40
|
+
)}
|
|
41
|
+
<slot name="head" />
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<slot />
|
|
45
|
+
</body>
|
|
46
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Home page filters (variant buttons, search box) combined on the same cards. Client-side module:
|
|
2
|
+
// every script importing it shares this state, so one filter never undoes the other.
|
|
3
|
+
const state = { variant: 'all', query: '' };
|
|
4
|
+
|
|
5
|
+
/** Lowercase, accents stripped: "Créer" matches "creer" */
|
|
6
|
+
export const normalize = (s: string) => s.normalize('NFD').replace(/\p{Diacritic}/gu, '').toLowerCase().trim();
|
|
7
|
+
|
|
8
|
+
export function setFilter(change: Partial<typeof state>) {
|
|
9
|
+
Object.assign(state, change);
|
|
10
|
+
const query = normalize(state.query);
|
|
11
|
+
const cards = [...document.querySelectorAll<HTMLElement>('.video-card')];
|
|
12
|
+
for (const card of cards) {
|
|
13
|
+
const variantOk = state.variant === 'all' || (card.dataset.variant ?? '') === state.variant;
|
|
14
|
+
// data-search is normalized at build time
|
|
15
|
+
const queryOk = !query || (card.dataset.search ?? normalize(card.textContent ?? '')).includes(query);
|
|
16
|
+
card.hidden = !(variantOk && queryOk);
|
|
17
|
+
}
|
|
18
|
+
// Hide sections left with no visible card
|
|
19
|
+
document.querySelectorAll<HTMLElement>('.category').forEach((section) => {
|
|
20
|
+
section.hidden = ![...section.querySelectorAll<HTMLElement>('.video-card')].some((card) => !card.hidden);
|
|
21
|
+
});
|
|
22
|
+
const visible = cards.filter((c) => !c.hidden).length;
|
|
23
|
+
document.dispatchEvent(new CustomEvent('pd:filter', { detail: { visible, query: state.query } }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Data helpers shared by every theme: the manifest (data/tutorials.json) in, page-ready values out.
|
|
2
|
+
import tutorials from '../data/tutorials.json';
|
|
3
|
+
import siteConfig from '../data/site-config.json';
|
|
4
|
+
import { siteLang, t } from '../i18n';
|
|
5
|
+
|
|
6
|
+
export type Step = { n?: number; at?: number; title?: string; key?: string; text?: string; image?: string; context?: boolean };
|
|
7
|
+
export type NumberedStep = Step & { num?: number };
|
|
8
|
+
export type Video = {
|
|
9
|
+
id: string;
|
|
10
|
+
slug?: string;
|
|
11
|
+
title: string;
|
|
12
|
+
category: string;
|
|
13
|
+
duration: string;
|
|
14
|
+
durationSeconds: number;
|
|
15
|
+
lang?: string;
|
|
16
|
+
langs?: string[];
|
|
17
|
+
variant?: string;
|
|
18
|
+
premium?: boolean;
|
|
19
|
+
file: string;
|
|
20
|
+
poster?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
stepsDetail?: Step[];
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
25
|
+
type Localized = string | Record<string, string>;
|
|
26
|
+
export type Category = { id: string; icon?: string; label: Localized; blurb?: Localized };
|
|
27
|
+
|
|
28
|
+
export const manifest = tutorials as any;
|
|
29
|
+
export const config = siteConfig as any;
|
|
30
|
+
export const allVideos: Video[] = manifest.videos;
|
|
31
|
+
/** Base path without trailing slash ('' at the root) */
|
|
32
|
+
export const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
|
33
|
+
|
|
34
|
+
/** A config text: a string, or one per language (falls back to the site language, then any) */
|
|
35
|
+
export function loc(value: string | Record<string, string> | undefined, lang?: string): string {
|
|
36
|
+
if (!value || typeof value === 'string') return value ?? '';
|
|
37
|
+
return value[lang ?? siteLang] ?? value[siteLang] ?? Object.values(value)[0] ?? '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** `*word*` in a config title marks emphasis: odd entries are emphasized ("Learn *fast*" → ['Learn ', 'fast', '']) */
|
|
41
|
+
export const emphasisParts = (s: string) => s.split(/\*(.+?)\*/);
|
|
42
|
+
/** The same title without the emphasis marks (for <title>, meta, alt) */
|
|
43
|
+
export const plainText = (s: string) => s.replace(/\*(.+?)\*/g, '$1');
|
|
44
|
+
|
|
45
|
+
export const media = (file: string) => `${base}/videos/${file}`;
|
|
46
|
+
export const videoHref = (v: Video) => `${base}/${v.id}/`;
|
|
47
|
+
export const homeOf = (lang?: string) => (!lang || lang === siteLang ? `${base}/` : `${base}/${lang}/`);
|
|
48
|
+
export const mmss = (sec: number) => `${Math.floor(sec / 60)}:${String(Math.floor(sec % 60)).padStart(2, '0')}`;
|
|
49
|
+
|
|
50
|
+
/** Every language a video was recorded in, sorted */
|
|
51
|
+
export const recordedLangs = (): string[] =>
|
|
52
|
+
([...new Set(allVideos.map((v) => v.lang).filter(Boolean))] as string[]).sort();
|
|
53
|
+
|
|
54
|
+
/** One tutorial across its languages: slug + variant */
|
|
55
|
+
export const tutorialKey = (v: Video) => `${v.slug ?? v.id}|${v.variant ?? ''}`;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Videos listed on a language's home page, in manifest order: each tutorial (slug + variant) once, in this
|
|
59
|
+
* language when recorded in it, else in its first recorded language — a missing translation never hides a tutorial.
|
|
60
|
+
*/
|
|
61
|
+
export function videosForLang(lang: string): Video[] {
|
|
62
|
+
const pick = new Map<string, Video>();
|
|
63
|
+
for (const v of allVideos) {
|
|
64
|
+
const k = tutorialKey(v);
|
|
65
|
+
if (!pick.has(k) || ((v.lang ?? siteLang) === lang && (pick.get(k)!.lang ?? siteLang) !== lang)) pick.set(k, v);
|
|
66
|
+
}
|
|
67
|
+
return allVideos.filter((v) => pick.get(tutorialKey(v)) === v);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Whole minutes of a list of videos, at least 1 */
|
|
71
|
+
export const minutesOf = (videos: Video[]) =>
|
|
72
|
+
Math.max(1, Math.ceil(videos.reduce((sum, v) => sum + (v.durationSeconds || 0), 0) / 60));
|
|
73
|
+
|
|
74
|
+
/** "3 videos · ~4 min" for a section */
|
|
75
|
+
export const sectionStats = (lang: string, videos: Video[]) => t(lang, 'sectionStats', { n: videos.length, m: minutesOf(videos) });
|
|
76
|
+
|
|
77
|
+
/** The app link for a page: the video's deep link, else the site's appUrl with {lang} resolved */
|
|
78
|
+
export const appHref = (lang: string, video?: Video): string | undefined =>
|
|
79
|
+
video?.links?.app ?? (config.appUrl ? String(config.appUrl).replaceAll('{lang}', lang) : undefined);
|
|
80
|
+
|
|
81
|
+
/** Sequential display numbers for numbered steps (contexts don't count) */
|
|
82
|
+
export function numberSteps(video: Video): NumberedStep[] {
|
|
83
|
+
let counter = 0;
|
|
84
|
+
return (video.stepsDetail ?? []).map((s) => ({ ...s, num: s.context ? undefined : ++counter }));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Poster: the recorded one, else the first step screenshot */
|
|
88
|
+
export const posterOf = (video: Video) => video.poster ?? numberSteps(video).find((s) => s.image)?.image;
|
|
89
|
+
|
|
90
|
+
/** Same tutorial (slug + variant) in every recorded language, sorted by language */
|
|
91
|
+
export const translationsOf = (video: Video) =>
|
|
92
|
+
allVideos
|
|
93
|
+
.filter((v) => tutorialKey(v) === tutorialKey(video))
|
|
94
|
+
.sort((a, b) => String(a.lang).localeCompare(String(b.lang)));
|
|
95
|
+
|
|
96
|
+
/** Previous / next video in a list (null at the ends) */
|
|
97
|
+
export function neighbours(list: Video[], video: Video): { prev: Video | null; next: Video | null } {
|
|
98
|
+
const at = list.findIndex((v) => v.id === video.id);
|
|
99
|
+
return { prev: at > 0 ? list[at - 1] : null, next: at >= 0 && at < list.length - 1 ? list[at + 1] : null };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Videos of the same language as `video`, in manifest order */
|
|
103
|
+
export const sameLang = (video: Video) => allVideos.filter((v) => (v.lang ?? '') === (video.lang ?? ''));
|
|
104
|
+
|
|
105
|
+
/** Category sections in manifest order, each with its videos (empty ones dropped) */
|
|
106
|
+
export function sections(videos: Video[]): (Category & { videos: Video[] })[] {
|
|
107
|
+
return Object.entries(manifest.categories as Record<string, Omit<Category, 'id'>>)
|
|
108
|
+
.map(([id, cat]) => ({ id, ...cat, videos: videos.filter((v) => v.category === id) }))
|
|
109
|
+
.filter((s) => s.videos.length > 0);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** <head> SEO data of a video page (JSON-LD is precomputed by scaffold when baseUrl is a full URL) */
|
|
113
|
+
export function videoSeo(video: Video) {
|
|
114
|
+
const poster = posterOf(video);
|
|
115
|
+
return {
|
|
116
|
+
type: 'video.other' as const,
|
|
117
|
+
image: poster ? media(poster) : undefined,
|
|
118
|
+
video: media(video.file),
|
|
119
|
+
alternates: translationsOf(video).filter((v) => v.lang).map((v) => ({ lang: v.lang!, href: videoHref(v) })),
|
|
120
|
+
jsonLd: video.jsonLd
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** <head> SEO data of a home page */
|
|
125
|
+
export const homeSeo = () => ({ alternates: recordedLangs().map((lang) => ({ lang, href: homeOf(lang) })) });
|
|
126
|
+
|
|
127
|
+
export const steps = { layout: (config.stepsLayout || 'text') as 'text' | 'cards' | 'full' | 'none', strip: config.showStrip !== false };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
// One home page per extra language (/en/, /ar/ …); the default language lives at /.
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import Home from '../../theme/Home.astro';
|
|
4
|
+
import { recordedLangs } from '../../lib/site';
|
|
5
5
|
import { siteLang } from '../../i18n';
|
|
6
6
|
|
|
7
7
|
export function getStaticPaths() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
return recordedLangs()
|
|
9
|
+
.filter((lang) => lang !== siteLang)
|
|
10
|
+
.map((lang) => ({ params: { lang } }));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const { lang } = Astro.params;
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
<
|
|
16
|
+
<Home lang={lang} />
|