jsx-xml icon indicating copy to clipboard operation
jsx-xml copied to clipboard

Async components support

Open remorses opened this issue 10 months ago • 0 comments

It would be great to have async components, in case a component is async the render function would return a promise that resolves when all components resolve

import { codeToTokens } from 'shiki'

export async function CodeSnippet({ code, lang, theme }) {
    const renderer = getSVGRenderer({
        fontFamily: 'monospace',
        fontSize: 14,
        bg: '#282c34',
    })
    const { tokens } = await codeToTokens(code, {
        lang,
        theme,
    })

    const svg = renderer.renderToSVG(tokens)
    return svg
}

remorses avatar Feb 26 '25 20:02 remorses