Skip to content

Improve docs site rendering performance by pre-rendering code blocks with shiki SSR mode #31

Description

@Greenheart

Really nice work with the latest updates and the new docs site! :)

I noticed the code blocks were rendering client side, and causing layout shifts as they completed after the main page load.

This could be improved with a simple change to use shiki in the SSR mode instead of rendering on the client side. This works well for the docs site since we know all content at build time, which means no dynamic client side rendering is needed and we can safely use SSR instead.

Here's an example implementation for how to use Shiki with SSR - feel free to copy the module into this project if you'd like:
https://github.com/Greenheart/greenheart.github.io/blob/8a45a6bba82dbe536ac56afc29563296678e5d09/src/lib/shiki-ssr.ts

And here is how the code blocks get preprocessed:
https://github.com/Greenheart/greenheart.github.io/blob/8a45a6bba82dbe536ac56afc29563296678e5d09/src/lib/markdoc.ts#L3

Let me know if you have any questions :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions