playwright-director 0.4.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 +264 -40
- package/dist/Tutorial.d.ts +2 -0
- package/dist/Tutorial.d.ts.map +1 -1
- package/dist/Tutorial.js +11 -3
- package/dist/Tutorial.js.map +1 -1
- package/dist/client.d.ts +33 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +72 -0
- package/dist/client.js.map +1 -0
- package/dist/init.js +16 -6
- package/dist/init.js.map +1 -1
- package/dist/merge.d.ts.map +1 -1
- package/dist/merge.js +2 -2
- package/dist/merge.js.map +1 -1
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +3 -0
- package/dist/reporter.js.map +1 -1
- package/dist/site/build-site.d.ts +24 -1
- package/dist/site/build-site.d.ts.map +1 -1
- package/dist/site/build-site.js +52 -10
- package/dist/site/build-site.js.map +1 -1
- package/dist/site/embed.d.ts +49 -18
- package/dist/site/embed.d.ts.map +1 -1
- package/dist/site/embed.js +53 -14
- 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 +83 -17
- package/dist/site/generate-manifest.js.map +1 -1
- package/dist/site/scaffold.d.ts +13 -0
- package/dist/site/scaffold.d.ts.map +1 -1
- package/dist/site/scaffold.js +86 -14
- package/dist/site/scaffold.js.map +1 -1
- package/dist/site/scan-tutorials.d.ts +6 -1
- package/dist/site/scan-tutorials.d.ts.map +1 -1
- package/dist/site/scan-tutorials.js +12 -8
- 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 +53 -0
- package/dist/site/strings.d.ts.map +1 -0
- package/dist/site/strings.js +145 -0
- package/dist/site/strings.js.map +1 -0
- 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 +84 -13
- 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/tts-provider.js +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/voice-dir.d.ts +9 -0
- package/dist/voice-dir.d.ts.map +1 -0
- package/dist/voice-dir.js +21 -0
- package/dist/voice-dir.js.map +1 -0
- package/dist/voice.d.ts +3 -0
- package/dist/voice.d.ts.map +1 -1
- package/dist/voice.js +29 -16
- package/dist/voice.js.map +1 -1
- package/package.json +9 -2
- package/schemas/embed-v1.schema.json +74 -0
- package/skills/tutorialize/SKILL.md +10 -2
- package/skills/tutorialize/agent.md +7 -0
- package/skills/tutorialize/references/api.md +20 -5
- package/skills/tutorialize/references/site.md +158 -0
- package/templates/site/public/widget.js +287 -145
- 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 +10 -107
- package/templates/site/src/components/VideoLinks.astro +19 -0
- package/templates/site/src/components/VideoModal.astro +66 -152
- package/templates/site/src/components/VideoPlayer.astro +43 -0
- package/templates/site/src/i18n.ts +19 -0
- 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 +16 -0
- package/templates/site/src/pages/[slug].astro +5 -738
- 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 -141
- package/templates/site/src/layouts/Base.astro +0 -56
- package/templates/site/src/styles/tutorials.css +0 -303
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/Youniwemi/playwright-director/schemas/embed-v1.schema.json",
|
|
4
|
+
"title": "playwright-director embed payloads, schema version 1",
|
|
5
|
+
"description": "Files written by `build-site` under <site>/embed/. All paths (video, poster, page, steps[].image) are relative to the site base URL: the directory that serves widget.js and embed/. Version 1 only gains optional fields; a breaking change bumps schemaVersion.",
|
|
6
|
+
"oneOf": [{ "$ref": "#/$defs/tutorial" }, { "$ref": "#/$defs/index" }],
|
|
7
|
+
"$defs": {
|
|
8
|
+
"tutorial": {
|
|
9
|
+
"title": "embed/<id>.json",
|
|
10
|
+
"type": "object",
|
|
11
|
+
"required": ["schemaVersion", "id", "title", "duration", "durationSeconds", "lang", "accent", "video", "page", "steps"],
|
|
12
|
+
"properties": {
|
|
13
|
+
"schemaVersion": { "const": 1 },
|
|
14
|
+
"id": { "type": "string", "description": "Video id: the tutorial name, plus -<variant> and .<lang> suffixes when recorded with them" },
|
|
15
|
+
"slug": { "type": "string", "description": "Id without the .<lang> suffix — groups the languages of one tutorial" },
|
|
16
|
+
"title": { "type": "string" },
|
|
17
|
+
"description": { "type": "string", "description": "Intro narration (leading context steps)" },
|
|
18
|
+
"duration": { "type": "string", "description": "m:ss display string, empty when unknown" },
|
|
19
|
+
"durationSeconds": { "type": "number", "minimum": 0 },
|
|
20
|
+
"lang": { "type": "string", "description": "Narration language (BCP 47 primary tag)" },
|
|
21
|
+
"langs": { "type": "array", "items": { "type": "string" }, "description": "All languages this tutorial exists in" },
|
|
22
|
+
"variant": { "type": "string", "description": "Recording variant, e.g. mobile" },
|
|
23
|
+
"accent": { "type": "string", "description": "Site primary color" },
|
|
24
|
+
"video": { "type": "string", "description": "Base-relative video path. Serve with HTTP Range (206) so seeking works." },
|
|
25
|
+
"poster": { "type": "string", "description": "Base-relative poster image" },
|
|
26
|
+
"page": { "type": "string", "description": "Base-relative path of the full tutorial page" },
|
|
27
|
+
"links": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"description": "Absolute URLs: the app screen this tutorial shows, and its documentation page",
|
|
30
|
+
"properties": { "app": { "type": "string" }, "docs": { "type": "string" } }
|
|
31
|
+
},
|
|
32
|
+
"steps": { "type": "array", "items": { "$ref": "#/$defs/step" } }
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"step": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"num": { "type": "integer", "minimum": 1, "description": "Display number; contexts have none" },
|
|
39
|
+
"at": { "type": "number", "minimum": 0, "description": "Start time in the video, seconds. Absent for screenshot-only steps." },
|
|
40
|
+
"title": { "type": "string", "description": "Human heading, never the raw i18n key" },
|
|
41
|
+
"key": { "type": "string", "description": "i18n key the step was declared with" },
|
|
42
|
+
"text": { "type": "string", "description": "Narration text" },
|
|
43
|
+
"image": { "type": "string", "description": "Base-relative screenshot path" },
|
|
44
|
+
"context": { "const": true, "description": "An unnumbered narration between steps" }
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"index": {
|
|
48
|
+
"title": "embed/index.json",
|
|
49
|
+
"type": "object",
|
|
50
|
+
"required": ["schemaVersion", "tutorials"],
|
|
51
|
+
"properties": {
|
|
52
|
+
"schemaVersion": { "const": 1 },
|
|
53
|
+
"defaultLang": { "type": "string" },
|
|
54
|
+
"tutorials": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"items": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"required": ["id", "title", "duration", "durationSeconds", "lang"],
|
|
59
|
+
"properties": {
|
|
60
|
+
"id": { "type": "string" },
|
|
61
|
+
"slug": { "type": "string" },
|
|
62
|
+
"title": { "type": "string" },
|
|
63
|
+
"duration": { "type": "string" },
|
|
64
|
+
"durationSeconds": { "type": "number" },
|
|
65
|
+
"lang": { "type": "string" },
|
|
66
|
+
"langs": { "type": "array", "items": { "type": "string" } },
|
|
67
|
+
"variant": { "type": "string" }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -7,11 +7,13 @@ description: Transform a Playwright E2E test into a narrated tutorial video. Loa
|
|
|
7
7
|
|
|
8
8
|
Turn a Playwright test into a tutorial that **teaches**, not just demonstrates.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Three reference files support this skill:
|
|
11
11
|
- [`references/storytelling.md`](references/storytelling.md) — Persona analysis, emotional arc, narration voice, pacing decisions
|
|
12
12
|
- [`references/api.md`](references/api.md) — `playwright-director` API, timing model, technical rules, checklist
|
|
13
|
+
- [`references/site.md`](references/site.md) — Gallery site (`build-site`): config, themes, sections, tokens/css/overrides, app + docs links, languages, SEO
|
|
13
14
|
|
|
14
|
-
**Read
|
|
15
|
+
**Read the first two before tutorializing.** Storytelling comes first — it drives every API decision.
|
|
16
|
+
Read `site.md` when you touch `tutorial-site.config.js`, a site override, or the test's `links`.
|
|
15
17
|
|
|
16
18
|
## Process
|
|
17
19
|
|
|
@@ -57,3 +59,9 @@ COMPLETE: Celebrate the outcome, suggest what's next
|
|
|
57
59
|
- Narration texts also become the gallery site's step-by-step guide
|
|
58
60
|
(`npx playwright-director build-site`) — even `skipVoice` steps show their
|
|
59
61
|
text there, so write every step text to read well on the page too.
|
|
62
|
+
- Each step's first sentence is its chapter title (gallery + in-app widget,
|
|
63
|
+
click = seek); for other locales, re-record with `TUTORIAL_LANG=xx` and let
|
|
64
|
+
the app follow `tutorial.lang` (`api.md` §1).
|
|
65
|
+
- Set `links: { app, docs }` when the tutorial shows an app screen or has a
|
|
66
|
+
docs page, and add the slug to a section's `items` in the site config
|
|
67
|
+
(`site.md` §3, §5).
|
|
@@ -13,6 +13,7 @@ You are an expert Tutorial Designer who transforms Playwright E2E tests into pro
|
|
|
13
13
|
Load the `/tutorialize` skill and read both reference files:
|
|
14
14
|
- `references/storytelling.md` — persona, emotional arc, narration voice
|
|
15
15
|
- `references/api.md` — API, timing model, technical rules, checklist
|
|
16
|
+
- `references/site.md` — gallery site config (only when the site config or `links` are involved)
|
|
16
17
|
|
|
17
18
|
## Your process
|
|
18
19
|
|
|
@@ -56,6 +57,12 @@ Follow all rules from `api.md`:
|
|
|
56
57
|
on distinct origins, each tab switch is acknowledged in the narration, and
|
|
57
58
|
split ratios (`focus(['a','b'], { ratio: [30, 70] })`) are used to keep the
|
|
58
59
|
acting pane readable
|
|
60
|
+
- Multi-language: the app UI follows `tutorial.lang` (set by `TUTORIAL_LANG`),
|
|
61
|
+
never a hard-coded locale; each step's first sentence becomes its chapter
|
|
62
|
+
title in the gallery and widget, so it must read well alone
|
|
63
|
+
- Gallery: `links: { app, docs }` on the Tutorial when the test shows an app
|
|
64
|
+
screen or has a docs page; new slugs go in a section's `items` of
|
|
65
|
+
`tutorial-site.config.js` (`site.md` §3, §5)
|
|
59
66
|
|
|
60
67
|
### 5. Show and explain
|
|
61
68
|
- Present the diff or full transformed code
|
|
@@ -25,9 +25,9 @@ Or use a fixture that wraps this (the consuming project typically provides a `tu
|
|
|
25
25
|
| Option | Type | Default | Description |
|
|
26
26
|
|---|---|---|---|
|
|
27
27
|
| `title` | `string` | *required* | Overlay title |
|
|
28
|
-
| `lang` | `string` | `'en'` |
|
|
28
|
+
| `lang` | `string` | `'en'` (`env TUTORIAL_LANG` wins) | Narration + TTS language. `TUTORIAL_LANG=xx` records one spec per language: outputs get `.<lang>`; read `tutorial.lang` to drive the app UI (`?lang=`) |
|
|
29
29
|
| `translate` | `(key: string) => string` | identity | i18n function — pass your `t()` |
|
|
30
|
-
| `audioBaseUrl` | `string` | `'http://localhost:5173'` |
|
|
30
|
+
| `audioBaseUrl` | `string` | `'http://localhost:5173'` | Origin the narration plays from — Playwright serves the clips from `tutorials/.cache/voice` (`TUTORIAL_VOICE_DIR`) |
|
|
31
31
|
| `testTitle` | `string` | auto | Raw test title (for reporter matching) |
|
|
32
32
|
| `testFile` | `string` | `''` | Test file path (metadata) |
|
|
33
33
|
| `projectName` | `string` | `''` | Playwright project name |
|
|
@@ -41,6 +41,7 @@ Or use a fixture that wraps this (the consuming project typically provides a `tu
|
|
|
41
41
|
| `mouseSteps` | `number` | `25` | Cursor animation smoothness |
|
|
42
42
|
| `customStyles` | `string` | built-in | CSS for overlay |
|
|
43
43
|
| `overlayPosition` | `'TL' \| 'TR' \| 'BL' \| 'BR'` | `'TR'` | Overlay corner position |
|
|
44
|
+
| `links` | `{ app?, docs? }` | — | Gallery buttons + docs cross-links: paths on the site's `appUrl` / `docsUrl`, or full URLs. No effect on the recording (`site.md` §5) |
|
|
44
45
|
| `variant` | `string` | `env TUTORIAL_VARIANT` | Suffixes `testName` (`<testName>-<variant>`) so a second recording never overwrites the first. `'mobile'` also compacts the overlay and pins the multi-scene split (see below) |
|
|
45
46
|
|
|
46
47
|
## 2. Core Methods
|
|
@@ -317,12 +318,25 @@ tutorials/
|
|
|
317
318
|
```
|
|
318
319
|
|
|
319
320
|
`npx playwright-director build-site` turns this directory into a static gallery
|
|
320
|
-
site
|
|
321
|
+
site (no astro needed in the project; `timelines` / `videos` in the site config
|
|
322
|
+
point elsewhere when `TUTORIAL_OUTPUT_DIR` is overridden). Besides the pages, the build emits `widget.js` + `embed/<slug>.json`
|
|
321
323
|
payloads so any app can embed a tutorial in-app: load
|
|
322
324
|
`<script src="<site>/widget.js" defer>` and add a `data-tutorial="<slug>"`
|
|
323
325
|
attribute to any element (slug = video id, i.e. the tutorial `name` plus
|
|
324
326
|
`-<variant>` if any). `window.PlaywrightDirector.open(slug)` is the programmatic
|
|
325
|
-
equivalent.
|
|
327
|
+
equivalent. Apps with their own player use the headless API:
|
|
328
|
+
`PlaywrightDirector.load(slug, { lang })` or, bundled,
|
|
329
|
+
`import { load } from 'playwright-director/client'` — the payload with absolute
|
|
330
|
+
URLs and chapter times (`steps[].at`, seconds). Schema:
|
|
331
|
+
`schemas/embed-v1.schema.json`.
|
|
332
|
+
|
|
333
|
+
Widget: a native modal `<dialog>` (focus trap, Esc, focus returned), chapters
|
|
334
|
+
that seek (arrows/Home/End), fr/en/ar strings picked from `data-tutorial-lang`
|
|
335
|
+
or `<html lang>`. Theme it from the app with `--pd-accent`, `--pd-surface`,
|
|
336
|
+
`--pd-text`, `--pd-muted`, `--pd-border`, `--pd-radius`, `--pd-font`,
|
|
337
|
+
`--pd-focus-ring` on `.playwright-director-widget`. The build writes `_headers`
|
|
338
|
+
(CORS + cache) for Cloudflare Pages / Netlify; `--base=/help/` deploys under a
|
|
339
|
+
sub-path, `-y` never prompts, `--only=<slug>` builds just that tutorial.
|
|
326
340
|
|
|
327
341
|
### Reviewing & correcting narration
|
|
328
342
|
|
|
@@ -336,7 +350,8 @@ lines in order (a key used twice corrects each occurrence in turn;
|
|
|
336
350
|
boundary and both halves replaced. Texts sourced from an i18n catalog, or a
|
|
337
351
|
first sentence that is the verbatim step key, are never rewritten — they are
|
|
338
352
|
reported with their key for a manual fix in the translations. Re-run with
|
|
339
|
-
`TUTORIAL_MODE=true` afterwards
|
|
353
|
+
`TUTORIAL_MODE=true` afterwards — `npx playwright test -g "<test title>"`
|
|
354
|
+
re-records just that tutorial; only changed TTS clips are regenerated
|
|
340
355
|
(content-hash caching). `npx tutorial-transcript` (no subcommand) just
|
|
341
356
|
regenerates the transcripts from the timeline JSON.
|
|
342
357
|
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Site Reference — the tutorial gallery (`build-site`)
|
|
2
|
+
|
|
3
|
+
`npx playwright-director build-site` turns the recordings (videos, timelines, step screenshots) into a
|
|
4
|
+
static Astro site: a home page per language, one page per video, SEO files, and the in-app widget data.
|
|
5
|
+
Config: `tutorial-site.config.js` at the project root (`--config=` for another path).
|
|
6
|
+
|
|
7
|
+
Read this before you edit a site config, add a theme override, or wire tutorials to the app and docs.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Minimal config
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
/** @type {import('playwright-director/site').SiteConfig} */
|
|
15
|
+
export default {
|
|
16
|
+
title: 'My App — Help',
|
|
17
|
+
input: 'tutorials/', // videos in <input>/videos, timelines in <input>/output
|
|
18
|
+
output: 'tutorial-site-dist/',
|
|
19
|
+
baseUrl: 'https://help.myapp.com/', // full URL = SEO on; a path ('/help/') = no absolute URLs
|
|
20
|
+
lang: 'fr,en,ar' // first = default language, served at /; the others at /<lang>/
|
|
21
|
+
};
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`baseUrl` must be a **full URL** to get canonical, hreflang, og:*, VideoObject JSON-LD, `sitemap.xml`,
|
|
25
|
+
`robots.txt` (host root only) and `links.json`. A bare path only sets the base path.
|
|
26
|
+
|
|
27
|
+
## 2. All options
|
|
28
|
+
|
|
29
|
+
| Option | Default | What it does |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `title` | *required* | Header + `<title>` |
|
|
32
|
+
| `logo` | — | Image path, copied to the site |
|
|
33
|
+
| `theme` | `'academy'` | `'academy'` (editorial: hero, sections, course sidebar) or `'classic'` (card carousel) |
|
|
34
|
+
| `tokens` | theme values | Design tokens → CSS variables (§4). Unknown names fail the build |
|
|
35
|
+
| `googleFonts` | theme fonts | `['Manrope:wght@400;600']`; `false` = load none |
|
|
36
|
+
| `css` | — | Extra stylesheet, loaded after the theme |
|
|
37
|
+
| `overrides` | — | Folder copied over the site `src/` — replaces any page, component or theme file (§4) |
|
|
38
|
+
| `appUrl` | — | App origin: resolves `links.app` paths; header button + call-to-action. `{lang}` is replaced |
|
|
39
|
+
| `docsUrl` | — | Docs origin for `links.docs` paths; `{lang}` is replaced by the tutorial language |
|
|
40
|
+
| `cta` | `true` | Académie "your turn" panel (needs an app link) |
|
|
41
|
+
| `themeSwitcher` | — | `{ Académie: '/help/', Classic: '/help/classic/' }` — links between builds |
|
|
42
|
+
| `input` / `output` | *required* | Recordings dir / built site dir |
|
|
43
|
+
| `timelines` / `videos` | `<input>/output`, `<input>/videos` | Override when `TUTORIAL_OUTPUT_DIR` differs |
|
|
44
|
+
| `baseUrl` | *required* | Full URL or path (§1) |
|
|
45
|
+
| `cors` | `'*'` | `_headers` Access-Control-Allow-Origin (widget on another origin); `false` = no file |
|
|
46
|
+
| `lang` | *required* | One language or a comma list (§6) |
|
|
47
|
+
| `strings` | built-in en/fr/ar | UI text overrides per language: `{ fr: { ctaButton: 'Essayer' } }` |
|
|
48
|
+
| `primaryColor` / `font` | — | Pre-0.6 spellings of `tokens.primary` / `tokens.fontBody` |
|
|
49
|
+
| `tutorials.categories` | from `@feature:` tags | Sections in display order (§3) |
|
|
50
|
+
| `tutorials.featured` | first video | Slug of the Académie "start here" video |
|
|
51
|
+
| `tutorials.premium` | `[]` | Slugs with a PRO badge |
|
|
52
|
+
| `tutorials.links` | test `links` | Per-slug `{ app, docs }`, over the test's |
|
|
53
|
+
| `tutorials.ui.heroTitle` | `title` | `*word*` marks emphasis (italic). String or `{ fr, en }` |
|
|
54
|
+
| `tutorials.ui.heroSubtitle` | "Video tutorials" | String or per language |
|
|
55
|
+
| `tutorials.stepsLayout` | `'text'` | Video page step guide: `'text'` \| `'cards'` \| `'full'` \| `'none'` |
|
|
56
|
+
| `tutorials.showStrip` | `true` | Thumbnail strip above the step guide |
|
|
57
|
+
|
|
58
|
+
## 3. Sections and order
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
tutorials: {
|
|
62
|
+
featured: 'onboarding',
|
|
63
|
+
premium: ['bank-reconciliation'],
|
|
64
|
+
categories: {
|
|
65
|
+
start: {
|
|
66
|
+
label: { fr: 'Premiers pas', en: 'Getting started' },
|
|
67
|
+
blurb: { fr: 'Créer son compte et sa première facture.', en: 'Account and first invoice.' },
|
|
68
|
+
items: ['onboarding', 'first-invoice'] // slugs, in reading order
|
|
69
|
+
},
|
|
70
|
+
billing: { label: 'Facturation', items: ['credit-note', 'recurring'] }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- Sections show in key order; videos in `items` order, then unlisted ones in scan order.
|
|
76
|
+
- `items` wins over the timeline `@feature:` tag. A slug = the test name without `.<lang>` / `-<variant>`,
|
|
77
|
+
so one entry covers every language and variant (`items`, `premium`, `featured`, `links` alike).
|
|
78
|
+
- Empty sections are dropped. Section stats ("3 videos · ~4 min") are computed.
|
|
79
|
+
|
|
80
|
+
## 4. Look: tokens → css → overrides
|
|
81
|
+
|
|
82
|
+
Use the lightest layer that does the job:
|
|
83
|
+
|
|
84
|
+
1. **`tokens`** — colors, radius, shadow, fonts:
|
|
85
|
+
`primary onPrimary accent bg surface text muted border pro radius shadow shadowHover fontBody fontDisplay`
|
|
86
|
+
→ `--pd-*` variables, written as `html:root { … }` so they beat the theme defaults.
|
|
87
|
+
Keep `primary` at 4.5:1 or more against `onPrimary` and `surface` (WCAG AA — the e2e suite runs axe).
|
|
88
|
+
2. **`css`** — any rule, loaded last. Target the stable classes (`.video-card`, `.ac-card`,
|
|
89
|
+
`.step-row`, `.video-modal`, …) or set `--pd-*` variables.
|
|
90
|
+
3. **`overrides`** — a folder mirroring the site `src/`: `overrides/theme/Home.astro` replaces the
|
|
91
|
+
theme's home page; `overrides/components/VideoLinks.astro` replaces a shared component. Last resort:
|
|
92
|
+
overridden files do not get package updates.
|
|
93
|
+
|
|
94
|
+
Copy order (later wins): `templates/site` → `templates/themes/<theme>` (as `src/theme/`) → `overrides`
|
|
95
|
+
→ generated data (`src/data/*.json`, `styles/user.css`, `public/*`).
|
|
96
|
+
|
|
97
|
+
## 5. Links to the app and the docs (cross-linking)
|
|
98
|
+
|
|
99
|
+
Declare them in the test — they are stored in the timeline and need no rebuild of the config:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const tutorial = new Tutorial(page, {
|
|
103
|
+
title: t('invoice.create'),
|
|
104
|
+
links: { app: '/invoices/new', docs: '/guides/invoices/' }, // paths on appUrl / docsUrl, or full URLs
|
|
105
|
+
// …
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- Video pages show "Open in the app" / "Read the docs" buttons; the Académie call-to-action uses the
|
|
110
|
+
video's app link, else `appUrl`.
|
|
111
|
+
- `links.json` (site root, full `baseUrl` only) maps each docs URL to its tutorials
|
|
112
|
+
(`slug, lang, url, title, poster, durationSeconds`), so the docs site can render "watch the video" cards.
|
|
113
|
+
- The widget payloads (`embed/<slug>.json`) carry `links` too.
|
|
114
|
+
|
|
115
|
+
## 6. Languages
|
|
116
|
+
|
|
117
|
+
- `lang: 'fr,en,ar'`: `/` = fr home, `/en/`, `/ar/` = the others; ar/he/fa/ur pages are RTL.
|
|
118
|
+
- Record one spec per language with `TUTORIAL_LANG=xx` (`api.md` §1). Each home lists every tutorial
|
|
119
|
+
once, in its language when recorded, else in its first recorded language — a missing translation
|
|
120
|
+
never hides a tutorial.
|
|
121
|
+
- UI strings: built-in en/fr/ar; `strings` adds or overrides keys. A new language starts from English.
|
|
122
|
+
Plurals: a `<key>_<category>` entry (`sectionStats_one`) is picked by `Intl.PluralRules`.
|
|
123
|
+
|
|
124
|
+
## 7. CLI
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npx playwright-director build-site # ./tutorial-site.config.js
|
|
128
|
+
npx playwright-director build-site --config=help.js
|
|
129
|
+
npx playwright-director build-site --theme=classic # override config.theme
|
|
130
|
+
npx playwright-director build-site --base=/help/ # override baseUrl's path
|
|
131
|
+
npx playwright-director build-site --output=dist/help/ # override output
|
|
132
|
+
npx playwright-director build-site --only=onboarding # only these slugs (all languages/variants)
|
|
133
|
+
npx playwright-director build-site -y # never prompt (CI; automatic without a TTY)
|
|
134
|
+
npx playwright-director build-site --dev # astro dev with live reload, no build
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Two themes from one config: build twice with `--theme` + `--base` + `--output`, and set
|
|
138
|
+
`themeSwitcher` so each build links to the other.
|
|
139
|
+
|
|
140
|
+
## 8. Output
|
|
141
|
+
|
|
142
|
+
| Path | Content |
|
|
143
|
+
|---|---|
|
|
144
|
+
| `index.html`, `<lang>/index.html` | Home per language |
|
|
145
|
+
| `<id>/index.html` | Video page (player + chapters, steps, prev/next, course sidebar) |
|
|
146
|
+
| `videos/` | Videos, posters, step screenshots |
|
|
147
|
+
| `sitemap.xml`, `robots.txt`, `links.json` | SEO + docs cross-links (full `baseUrl` only) |
|
|
148
|
+
| `embed/*.json`, `widget.js`, `client.js` | In-app help widget + headless data API |
|
|
149
|
+
| `_headers` | CORS + cache rules (Cloudflare Pages / Netlify) |
|
|
150
|
+
|
|
151
|
+
## 9. Checklist
|
|
152
|
+
|
|
153
|
+
- [ ] `baseUrl` is a full URL in production (SEO files and JSON-LD need it)
|
|
154
|
+
- [ ] Every recorded slug is in a section's `items` (or has a meaningful `@feature:` tag)
|
|
155
|
+
- [ ] `featured` names an existing slug
|
|
156
|
+
- [ ] Tests that show an app screen set `links.app`; tests with a docs page set `links.docs`
|
|
157
|
+
- [ ] Customization uses tokens first, `css` second, `overrides` last
|
|
158
|
+
- [ ] `--only` builds are for checking a page — deploy a full build
|