preactjs / preact-www

:book: Preact documentation website.
https://preactjs.com
MIT License
358 stars 500 forks source link

refactor: Precompile markdown on the server #1118

Closed rschristian closed 6 months ago

rschristian commented 6 months ago

With our site being statically generated, we really don't have any need to compile the markdown to HTML on the client -- everything can be done ahead of time on the server, and so that's what this PR does.

It serializes to JSON, which I'm not 100% sure of. It's a marginal size increase over the raw .md files, but does come with the table of contents data too, so apples-to-apples, it's a tiny decrease. Might be a better format though? I did take a look at serving it as HTML directly (HTML partial sorta thing), but with the meta data JSON serialized in a script tag, it ended up being marginally larger than this (w/ gzip, anyhow)

Drops (transferred) client-side JS by ~15kb or so. Tiny decrease in render times on nav too of course.