Skip to content

feat(sync-content): mirror docs/cli image and PDF assets into the site - #16

Merged
agentiknet merged 1 commit into
mainfrom
docs-assets-sync
Oct 2, 2026
Merged

agentiknet merged 1 commit into
mainfrom
docs-assets-sync

Conversation

@agentiknet

@agentiknet agentiknet commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Why

Guides in agentproto/ts can now embed screenshots and link a downloadable PDF (see agentproto/ts#1458, a phone-pairing guide), but scripts/sync-content.mjs's walkMarkdown() only ever collected files ending .md or named meta.json — there was no path that copied a binary asset from docs/cli/** into content/docs/**. Any relative image or PDF link in a guide 404s once synced onto this site.

What

sync-content.mjs now also walks and copies matched assets (png/jpg/jpeg/gif/svg/webp/pdf) from the source tree, to two destinations, for two different reasons (documented at length in the new header comment):

  • content/docs/<rel> — fumadocs-mdx's remarkImage plugin (fumadocs-core/dist/mdx-plugins/remark-image.js) rewrites a relative ![]() image src into a static import, resolved against the compiled .mdx file's own directory. Turbopack/webpack need the real file sitting there at build time for that import to resolve — this is never served from public/.
  • public/docs/<rel> — a plain markdown link (e.g. "Download this guide as a PDF") is a link node, not an image node, so remarkImage never touches it — it reaches the page as a literal relative href. The browser resolves that against the page's own URL (/docs/<rel-page-path>, since docsSource mounts content/docs at baseUrl: "/docs"). Next.js serves public/ files at that same path ahead of the [[...slug]] docs catch-all route, so mirroring the asset there is what actually turns the link into a 200 instead of a 404 through the docs route.

Also: public/docs added to .gitignore (synced/generated, same as content/docs) and to the clean script.

pnpm-lock.yaml is intentionally not committed here — this repo doesn't currently track one; I generated it locally only to pnpm install/build in an isolated worktree.

How I proved it

Built an isolated worktree (git worktree add -b docs-assets-sync ... origin/main, so as not to touch the main checkout's own uncommitted work on another branch) and pointed sync-content.mjs's sibling-repo detection at agentproto/ts#1458's worktree via a ../ts symlink (the same mechanism the script already supports for a local sibling checkout — no code change needed for that part).

  • node scripts/sync-content.mjs — synced 63 docs + 6 assets (5 screenshots + 1 PDF) to both content/docs/guides/assets/phone-pairing/ and public/docs/guides/assets/phone-pairing/.
  • pnpm build (next build, Turbopack): exit 1 — but for a reason unrelated to this change: docs/cli/verbs/pair.md (pre-existing content, last touched by an unrelated commit 2bc6692f well before #1458) has a raw from <daemon>; scan a new pairing QR in prose, which MDX parses as an unclosed JSX tag (Expected a closing tag for <daemon>) and which the static generateStaticParams() build enumerates for every page, failing the whole build. I confirmed this is pre-existing and independent of my change by reverting my sync-content.mjs edit and rebuilding from a clean .next: same file, same MDX error, and (before that) the expected Module not found: Can't resolve './assets/phone-pairing/*.png' errors from the unfixed script — i.e. the un-fixed script fails exactly the way this PR fixes, confirming the root cause. The <daemon> bug is a separate, pre-existing docs-authoring issue in agentproto/ts I'm not fixing here (out of scope for this repo).
  • To actually exercise the render (since next start needs a completed build), I ran next dev (Turbopack, which compiles routes on demand rather than enumerating every static page up front) and, only for this proof, locally patched the generated (gitignored, non-committed) content/docs/verbs/pair.mdx copy to escape that one <daemon> — purely to unblock reaching /docs/guides/phone-pairing in dev; nothing under content/docs/ or public/docs/ is part of this PR's diff.
    • GET /docs/guides/phone-pairing → 200
    • All 5 screenshots render via next/image's static import (/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fconfirm-fingerprint.<hash>.png&... etc.) — fetched one directly: 200, image/png.
    • The PDF link renders as href="./assets/phone-pairing/phone-pairing-guide.pdf"; fetching the browser-resolved absolute path GET /docs/guides/assets/phone-pairing/phone-pairing-guide.pdf → 200, application/pdf, 7 pages (matches the source PDF).
    • Screenshot of the rendered page (headless Chrome) confirms the first screenshot displays correctly in place, with sidebar nav and TOC intact.

Follow-up (not in this PR)

docs/cli/verbs/pair.md's <daemon> placeholder breaks next build for the entire site today (it's enumerated by generateStaticParams), independent of anything here. Worth a one-line fix on the agentproto/ts side (backtick it: `<daemon>`) so pnpm build actually succeeds end to end — flagging it here since I hit it while testing, not fixing it in this PR (different repo, out of scope for this change).

Never merge

Not merging this myself — reporting the PR for review.


🤖 @agentproto-bot — PR · session sess_39ac1d77 (rdv-browser: phone pairing guide page) · claude-code / subscription · auth-profile Claude Subs Agentik · model claude-sonnet-5 · supervisor sess_d3e835f4 · $6.0454 (daemon) · host mac.home · cwd agentproto/phone-pairing-guide

Guides in agentproto/ts can now embed screenshots and link a PDF, but
sync-content.mjs only ever copied .md/meta.json — any relative image
or PDF reference 404s once synced. Copy matched assets (png/jpg/gif/
svg/webp/pdf) to two places: content/docs/<rel>, where fumadocs-mdx's
remarkImage plugin resolves a relative markdown image as a static
import against the compiled .mdx file's own directory; and
public/docs/<rel>, where Next serves it ahead of the docs catch-all
route at the exact path a relative link resolves to from the page's
own URL. Proved against agentproto/ts#1458's phone-pairing guide: all
5 screenshots and the PDF link render/200 through a real `next dev`
render of the page.
@agentiknet
agentiknet merged commit 16a4430 into main Oct 2, 2026
1 of 2 checks passed
@agentiknet
agentiknet deleted the docs-assets-sync branch November 5, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant