codex/next-markdown-exports deployment.Codesandbox
Summary
Embed live CodeSandbox examples.
Linked previews use shadcn Card with optional title, description and Badge tags. The preview
image or placeholder remains the link to CodeSandbox. Interactive embeds keep their iframe.
Give the sandbox a preview image with img. Like an <img src>, it can be relative to
the article:
|-- authoring
| |-- codesandbox.mdx <= relative to this article
| `-- cell-fracture.webp
<Codesandbox id="3rjsl" title="Cell fracture" img="cell-fracture.webp" />
result:
A relative img gets its dimensions added automatically, just as a relative Img does.
A full URL (img="https://…") works too, as is.
The same image is the page's thumb in the Entries listing.
Without img
CodeSandbox no longer serves screenshots of sandboxes, so without img a placeholder stands in,
still linking to the sandbox:
<Codesandbox id="3rjsl" title="Cell fracture" />
result:
Optional metadata can accompany either an image or a placeholder:
<Codesandbox
id="3rjsl"
title="Cell fracture"
description="Explore a physics example with Rapier."
tags={["physics", "rapier"]}
/>
With only an id, the placeholder link is still labelled CodeSandbox followed by that id.
screenshot_url is the former name of img. It still works, but is deprecated.
