blog/Teaching the blog to draw: Mermaid at build time

Teaching the blog to draw: Mermaid at build time

#mermaid #copilot #astro #security #supply-chain

In the previous post I walked through how this site is hosted, and used a diagram to do it. That diagram is not a screenshot or a hand-drawn SVG: it is Mermaid, written as plain text in Markdown. It fits my markdown-as-content approach nicely, so I wanted it wired in properly rather than bolted on.

The whole thing is rendered to a static image at build time, so the page ships zero JavaScript for diagrams and needed no changes to the site’s strict Content-Security-Policy. Here is what went in, most of it driven by asking Copilot and then keeping it on task:

What went in

The stale dependency in the room

Speaking of installing a pile of npm packages just to draw a box and an arrow: that is exactly the kind of thing that can quietly ship a malicious postinstall and walk off with your cloud credentials. The very plugin drawing these diagrams has not shipped a release in about a year, and I used it anyway, because it only runs at build time and, worst case, I can fork it. On a client’s production system I would think twice; on a personal blog, with no users and no data to lose, it is a calculated bet I am happy to make. How I weigh that difference, and lock down the rest, deserves its own post, so more on securing the supply chain soon.

References

The tools and docs that made this possible, if you want to dig deeper: