Skip to content

fix(#1421): resolve replace-image-src against md/mdx frontmatter - #440

Merged
davidwkeith merged 1 commit into
mainfrom
claude/issue-1421-frontmatter-image
Aug 12, 2026
Merged

fix(#1421): resolve replace-image-src against md/mdx frontmatter#440
davidwkeith merged 1 commit into
mainfrom
claude/issue-1421-frontmatter-image

Conversation

@davidwkeith

Copy link
Copy Markdown
Contributor

Summary

  • `apply_edit`'s `replace-image-src` op always refused with `no-match` / "no .mdoc files found" against the stock template's example photo page, because none of the existing resolvers (`.mdoc`, Keystatic, `.astro`) can patch an image whose `src` comes from Markdown/MDX frontmatter rendered through a dynamic expression (e.g. `` in `Hentry.astro`).
  • Adds `resolveFrontmatterImage` to `server/patcher.mjs`'s resolver chain: for `replace-image-src` edits, it scans `.md`/`.mdx` files under `src/content` for a top-level frontmatter field (quoted or plain-scalar) whose value matches the drop target's current `src`, and patches just that value in place. Matches on value, not field name, since different content collections use different keys.
  • No MCP schema change — reuses the existing `replace-image-src` op and payload shape.

Paired PR check

  • This change is self-contained to the plugin (skills / hooks / template / docs / MCP server with no consumer-visible contract change).
  • This change needs a paired PR in Anglesite/Anglesite-app.

Test plan

  • Plugin self-checks pass (npm test — 3158 passed, 1 pre-existing unrelated failure in test/optimize-images-packaging.test.js due to a missing tsx binary in this fresh worktree, not touched by this change)
  • Added test/fixtures/patcher/src/content/photos/*.md fixtures and describe("frontmatter image resolver", …) in test/patcher.test.js covering: quoted value match, unquoted plain-scalar match, no-match refusal, and ambiguous refusal (two files sharing the same image value)
  • If touching the MCP server: paired app PR exercises the new/changed messages — N/A, no schema/op change

Closes Anglesite/Anglesite#1421

Add a resolver that patches a content-collection frontmatter field
(e.g. `image: "/x.svg"`) when its value matches the drop target's
src. Layouts that render frontmatter through a dynamic expression
(`<img src={d.image} />`) have no literal <img src> for the .astro
resolver to find and no .mdoc body text for the .mdoc resolver to
match, so drag-drop image replacement always refused with
"no .mdoc files found" on stock (.md-content) sites.

Anglesite/Anglesite#1421
@davidwkeith
davidwkeith merged commit ea171ce into main Aug 12, 2026
4 checks passed
@davidwkeith
davidwkeith deleted the claude/issue-1421-frontmatter-image branch August 12, 2026 20:56
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.

replace-image-src fails on md-frontmatter images: "no .mdoc files found"

1 participant