Skip to content

feat(mdx): click-to-expand images in docs and blog#379

Open
kubeboiii wants to merge 1 commit into
kagent-dev:mainfrom
kubeboiii:fix/362-mdx-click-to-expand-images
Open

feat(mdx): click-to-expand images in docs and blog#379
kubeboiii wants to merge 1 commit into
kagent-dev:mainfrom
kubeboiii:fix/362-mdx-click-to-expand-images

Conversation

@kubeboiii
Copy link
Copy Markdown
Contributor

@kubeboiii kubeboiii commented Jun 2, 2026

Closes #362

Summary

Adds click-to-expand for images in docs and blog MDX. Markdown images route through MdxFigure, which renders a clickable thumbnail and opens a dialog with a larger view of the same file. Two doc/blog pages that used raw <img> tags now use MdxFigure or markdown image syntax so they get the same behavior.

Changes

  • src/components/mdx/mdx-figure.tsx: Client component with next/image thumbnail, optional figcaption from markdown title, lazy-loaded lightbox (next/dynamic, ssr: false), aria-label / dialog attributes. Optional style / className apply to <figure> for page-specific layout.
  • src/components/mdx/mdx-figure-lightbox.tsx: Radix dialog; native <img> with viewport max dimensions; DialogContent uses w-auto so the modal fits the image.
  • src/components/ui/dialog.tsx: shadcn dialog primitive.
  • package.json: @radix-ui/react-dialog.
  • src/mdx-components.tsx: img maps to <MdxFigure />; export MdxFigure for explicit MDX use.
  • src/app/docs/kagent/examples/telegram-bot/page.mdx: Replace two <img> elements with <MdxFigure /> (width: 55% / minWidth: 300px and width: 40% / minWidth: 250px on <figure>).
  • src/blogContent/kagent-celebrating-100-days.mdx: Replace one HTML <img> with markdown ![...](...).

Default MDX images remain full width in the prose column (same as main). The dialog provides the enlarged view. Telegram bot keeps its previous percentage-based widths.

Also fixes MDX img alt: main passed props.title to Image alt instead of props.alt.

Out of scope

Homepage and other non-MDX images are unchanged.

Test plan

  • npm run lint
  • npm run build
  • /docs/kagent/examples/slack-a2a: inline images, open dialog, close with X / Escape
  • /docs/kagent/examples/telegram-bot: GIF and architecture diagram size; open dialog on architecture image
  • /docs/kagent/getting-started/first-agent: sample docs page
  • /blog/kagent-celebrating-100-days: markdown image and dialog

Screenshots

Default docs (markdown images)

Inline — full prose column width; image is clickable.

First Agent inline

Lightbox — click opens dialog; image fits viewport; close with X or Escape.

First Agent lightbox

Custom layout (explicit MdxFigure)

Telegram bot page — GIF (~55%) and architecture diagram (~40%) unchanged from intended layout.

Telegram inline layout

Lightbox — architecture diagram enlarged in dialog.

Telegram lightbox

Blog

Markdown image — same click-to-expand behavior as docs.

Blog lightbox

Add MdxFigure for docs and blog MDX images: clickable next/image thumbnail
and a Radix dialog lightbox with a viewport-fitted view. Lazy-load lightbox
code (next/dynamic, ssr: false). Fix alt text to use markdown alt instead of
title. Convert remaining raw img tags on the telegram bot page and one blog
post. Preserve telegram bot figure widths (55% / 40%).

Closes kagent-dev#362

Signed-off-by: Himanshu <kubeboiii@users.noreply.github.com>
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.

render smaller images that can be opened in a bigger size when clicking on them

1 participant