` elements
* and the client doesn't have to load any highlighter JS. The copy
* button is the only interactive bit and lives in CopyButton, a tiny
* client component.
*
* Default theme is `github-dark` — matches the Hermes/Docusaurus look
* the user asked us to emulate. Default language is bash because most
* snippets in the docs are shell commands.
*
* Defensive fallback: if Shiki can't tokenize the requested language
* (unknown alias, unsupported grammar) we fall back to a plain
* dark-background so the page never crashes.
*/
const CopyableCode = async ({ code, language = "bash", className }: CopyableCodeProps) => {
let html: string
try {
html = await codeToHtml(code, {
lang: language,
theme: "github-dark",
})
} catch {
// Unknown lang or grammar error → render as plain text on a dark
// background to preserve the visual style without colour.
const escaped = code
.replace(/&/g, "&")
.replace(//g, ">")
html = `${escaped}
`
}
return (
)
}
export default CopyableCode