Skip to content

Commit c25525f

Browse files
committed
fix(site): actually use both themes of every screenshot
Capture rendered 10 images; the docs referenced 5. The other five were dead weight, and the ones in use mixed themes arbitrarily — topology-light sat among four dark shots, which reads as a mistake rather than a choice. A docs site with a theme toggle should show the matching screenshot, so both are now emitted per view and Starlight's own light:sl-hidden / dark:sl-hidden utilities pick one. That is the mechanism Starlight's docs use for theme-specific images, so it tracks the toggle with no script of ours. Needed MDX for the two pages, since a themed pair can't be expressed as a markdown image. ThemedShot resolves the pair via an eager import.meta.glob so Astro still optimises both to webp, and throws a named error pointing at if one is missing — verified by deleting one. Claude-Session: https://claude.ai/code/session_01RgSnMCa3JQigphGnPbazdw
1 parent 93a70bf commit c25525f

3 files changed

Lines changed: 64 additions & 14 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
// A device-UI screenshot that follows the reader's theme.
3+
//
4+
// capture.mjs renders every view in both themes. Showing only one of them means
5+
// half the readers see a dark screenshot on a light page (or the reverse), and
6+
// it also left five generated images unused. Both are emitted here and Starlight's
7+
// own `light:sl-hidden` / `dark:sl-hidden` utilities pick one — the same
8+
// mechanism its docs use for theme-specific images, so it stays in sync with
9+
// the theme toggle without any script of ours.
10+
//
11+
// `name` is the view stem: "dashboard" resolves dashboard-light.png and
12+
// dashboard-dark.png.
13+
import { Image } from 'astro:assets';
14+
15+
interface Props {
16+
name: string;
17+
alt: string;
18+
}
19+
const { name, alt } = Astro.props;
20+
21+
// import.meta.glob is eager so Astro processes and optimises both files at
22+
// build time; a runtime import() would leave them unoptimised.
23+
const shots = import.meta.glob<{ default: ImageMetadata }>(
24+
'../assets/screenshots/*.png',
25+
{ eager: true },
26+
);
27+
28+
const pick = (theme: string) => {
29+
const key = `../assets/screenshots/${name}-${theme}.png`;
30+
const mod = shots[key];
31+
if (!mod) {
32+
throw new Error(
33+
`ThemedShot: no screenshot at ${key}. ` +
34+
`Run \`npm run screenshots\` — these are generated, not committed.`,
35+
);
36+
}
37+
return mod.default;
38+
};
39+
---
40+
41+
<Image src={pick('light')} alt={alt} class="tigo-shot dark:sl-hidden" loading="lazy" />
42+
<Image src={pick('dark')} alt={alt} class="tigo-shot light:sl-hidden" loading="lazy" />
43+
44+
<style is:global>
45+
.tigo-shot {
46+
width: 100%;
47+
height: auto;
48+
border-radius: 0.5rem;
49+
border: 1px solid var(--sl-color-gray-5);
50+
}
51+
</style>

site/src/content/docs/guides/getting-started.md renamed to site/src/content/docs/guides/getting-started.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Start Here
33
description: What Tigo Monitor does, what you need to buy, and the five steps from parts on the desk to a live per-panel dashboard.
44
---
5+
import ThemedShot from '../../../components/ThemedShot.astro';
6+
57

68
If your roof has Tigo optimizers on it, your panels are already reporting how much
79
power each one makes. That information goes to Tigo's box and, usually, to Tigo's
@@ -14,8 +16,7 @@ equipment, so it can't disturb anything.
1416

1517
## What you'll end up with
1618

17-
![The Tigo Monitor dashboard: a coloured tile per panel, grouped by string, with
18-
one shaded panel showing amber.](../../../assets/screenshots/dashboard-dark.png)
19+
<ThemedShot name="dashboard" alt="The Tigo Monitor dashboard: a coloured tile per panel, grouped by string, with one shaded panel showing amber." />
1920

2021
- A web page on your home network showing **every panel individually** — watts,
2122
volts, amps, temperature — updating live.

site/src/content/docs/guides/web-server.md renamed to site/src/content/docs/guides/web-server.mdx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Web Server & API
33
---
4+
import ThemedShot from '../../../components/ThemedShot.astro';
5+
46

57
The device serves its own dashboard. Type its IP address into any browser on your
68
home network and it's there — no app to install, nothing to sign into, and it
@@ -24,23 +26,19 @@ anyone who wants to pull the numbers into their own scripts.
2426

2527
### What it looks like
2628

27-
![Dashboard — a tile per panel, grouped by string. The amber tile is a shaded
28-
panel.](../../../assets/screenshots/dashboard-dark.png)
29+
<ThemedShot name="dashboard" alt="Dashboard — a tile per panel, grouped by string. The amber tile is a shaded panel." />
2930

30-
![History — power and energy over the selected range, read from the on-device
31-
database.](../../../assets/screenshots/history-dark.png)
31+
<ThemedShot name="history" alt="History — power and energy over the selected range, read from the on-device database." />
3232

33-
![Topology — your array as inverter, string and panel, with live
34-
readings.](../../../assets/screenshots/topology-light.png)
33+
<ThemedShot name="topology" alt="Topology — your array as inverter, string and panel, with live readings." />
3534

36-
![Node Table — every panel the device has seen, sortable and
37-
filterable.](../../../assets/screenshots/nodes-dark.png)
35+
<ThemedShot name="nodes" alt="Node Table — every panel the device has seen, sortable and filterable." />
3836

39-
![Diagnostics — memory, network, UART counters and time-series database
40-
stats.](../../../assets/screenshots/diagnostics-dark.png)
37+
<ThemedShot name="diagnostics" alt="Diagnostics — memory, network, UART counters and time-series database stats." />
4138

42-
These are generated automatically from the current UI against synthetic data —
43-
no real install's serials, addresses or account details appear in them.
39+
These are generated from the current UI against synthetic data — no real
40+
install's serials, addresses or account details appear in them. They follow
41+
this page's theme, so what you see is what the device will look like for you.
4442

4543
### Two things worth knowing
4644

0 commit comments

Comments
 (0)