Commit c23a5c4
committed
Serve docs content images from shared R2 bucket instead of git
Content images under content/docs/images/ were committed as binary
files and referenced from MDX with relative paths (../images/foo.png).
fumadocs-mdx's static-export bundler resolved those at build time into
content-hashed files, which meant the image bytes had to be physically
present in the repo just to run `next build`. That's a growing repo
and doesn't fit the shared image-hosting setup other Abstract Machines
properties are moving to (a single R2 bucket, proxied same-origin so
URLs don't change, with immediate cache purge on update).
Since this site is a pure Next.js static export with no server runtime
in production (deployed as Cloudflare static assets, no next-on-pages
or opennextjs/cloudflare), there's no Next.js request handler to reach
an R2 binding from. Instead, wrangler.jsonc now has a `main` Worker
script that falls back from the ASSETS binding (only when no static
file matches, since run_worker_first defaults to false) to reading
`/docs/hardware/img/*` straight out of the shared `websites-images`
bucket, under the `hardware-docs` key prefix.
The first pass of this migration also changed MDX authoring syntax
(relative paths -> absolute `/img/<file>`) and added a
width/height JSON manifest (src/lib/image-dimensions.json) rendered
through next/image, so every new image required a manual manifest
entry or the build would throw. That's more ceremony than this change
should require: authors should keep writing plain markdown image
syntax with whatever relative path they always used, and nothing about
next/image's optimizer is actually usable here anyway (this is a
static export with no image-optimization server, `unoptimized` was
already set).
This commit reverts the MDX content and syntax to their original form
and replaces DocImage/next/image with a plain, zoomable `<img>`:
- content/docs/**/*.mdx: reverted to the original relative-path
markdown image syntax (`../images/foo.png`)
- src/lib/remark-doc-images.ts: new remark plugin that resolves each
image's relative path against content/docs/images/ at compile time
(pure path math, no image bytes needed) into the literal
`/docs/hardware/img/...` URL the Worker serves — replaces
fumadocs-mdx's remarkImage, which needs the file on disk
- source.config.ts: disable remarkImageOptions, wire in
remarkDocImages
- src/mdx-components.tsx: render the `img` MDX node as a plain
`<img>` (no next/image, no width/height) wrapped in ImageZoom for
click-to-zoom, passing `src`/`alt` to ImageZoom itself as well as
the inner `<img>` — ImageZoom's zoomed-in view reads its image from
that prop directly, not from `children`
- src/components/doc-image.tsx, src/lib/image-dimensions.json:
removed, no longer needed
- worker/index.ts, wrangler.jsonc: unchanged from the first pass
- scripts/publish-image.mjs, scripts/README.md,
scripts/.env.publish-image.example: maintainer-only upload+purge CLI
and its docs, unchanged from the first pass1 parent daf1569 commit c23a5c4
68 files changed
Lines changed: 526 additions & 4221 deletions
File tree
- content/docs
- base-board
- images
- scripts
- src
- lib
- worker
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
| |||
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
49 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
50 | 59 | | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
| |||
73 | 83 | | |
74 | 84 | | |
75 | 85 | | |
| 86 | + | |
| 87 | + | |
76 | 88 | | |
77 | 89 | | |
78 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 commit comments