A PBIX.info share link used to arrive in chat as a bare URL, or with the same generic homepage card for every model. Now a link like pbix.info/share/gRBJ1JK6RV unfurls into a picture of the model itself: the file name, the table and relationship counts, and a miniature of the relationship diagram.

The Adventure Works DW 2020 share, unfurled: nine tables, eleven relationships, the diagram drawn from the stored layout.
This post covers how that works. There are three parts: tags in the HTML, an image rendered on demand, and enough caching to make the image cheap.
How Unfurling Works
When you paste a URL into Slack, Teams, Discord, LinkedIn or X, the platform’s crawler fetches the page and reads <meta> tags from the <head>: Open Graph (og:title, og:description, og:image) and the older twitter:* set. The card you see is built entirely from those tags.
The catch is that crawlers do not run JavaScript. PBIX.info is a single-page React app: every route is served the same index.html, and the share is fetched and rendered client-side. A crawler visiting /share/gRBJ1JK6RV sees the homepage’s tags, so every share link unfurled identically.
So the tags have to be correct in the HTML the server sends.
Rewriting the Shell at the Edge
PBIX.info runs on Cloudflare Pages, and shares live in a D1 (SQLite) table. A Pages Function at functions/share/[id].ts now takes over /share/:id:
- fetch the static
index.htmlfrom the asset store - look up the share in D1
- stream the HTML through
HTMLRewriter, replacing the title, description,og:*andtwitter:*tags
The browser still gets the same SPA shell and boots normally. Only the <head> changes.
The description needs counts of tables, relationships and measures. Those live inside large JSON blobs (the serialized diagram and the extracted DAX/M code), and there is no reason to pull megabytes into the worker just to count array elements. SQLite can count them where they are stored:
SELECT file_name,
json_array_length(flow_diagram_data, '$.nodes') AS tables,
json_array_length(flow_diagram_data, '$.edges') AS relationships,
json_array_length(m_dax_code, '$.daxExpressions') AS measures
FROM shared_diagrams
WHERE unique_id = ?
Only four small values leave D1. If an old row has malformed JSON, the query falls back to the file name alone, and the page is always served even if D1 is unavailable.
The rewrite also adds og:image:width/height/alt, and up to two twitter:label/twitter:data pairs that Slack shows as small “Tables” and “Measures” fields under the description.

The rewritten tags, as an Open Graph previewer sees them.
Drawing the Diagram Without a Browser
Text-only cards are fine, but the useful part of a share is the diagram. A second function, functions/share/[id]/og.png.ts, renders a 1200×630 PNG for each share.
There is no headless browser at the edge, and React Flow is not going to run there. The card is built the low-tech way: a function that turns the stored React Flow JSON into an SVG string, and resvg compiled to WebAssembly (@resvg/resvg-wasm) to turn that SVG into a PNG.
The SVG is a simplified redraw of what the app shows, not a screenshot:
- Positions come from the stored nodes. These are the positions from the PBIX’s own
DiagramLayout, so the card resembles the author’s arrangement. The whole diagram is scaled to fit the card, but never enlarged past 1:1, so a three-table model does not get cartoonishly large. - Tables show only relationship columns. This matches the app’s compact view: key columns plus a “+N more” row. A wide fact table stays readable.
- Edges are orthogonal. Each relationship connects the actual column rows on either side, choosing the closest left/right pair. A small router produces one of three shapes: both ends on the same side (go out past the further one and come back), facing each other (a vertical jog at the midpoint), or facing away (a five-segment route that steps out, crosses at mid-height, and steps back in). Corners are rounded with quadratic curves. It is not React Flow’s router, but it is close enough to read the model at a glance.
- Lines are thick. Previews are viewed small, so edges are 3px (thinning on very dense models). Inactive relationships keep their dashes.
Text needs real fonts: resvg has no system fonts at the edge. The card uses JetBrains Mono, subset into Latin, Latin Extended and Cyrillic TTFs and served as static assets. One gotcha: resvg picks the first loaded face that matches family and weight, so the Latin subset has to be loaded first. Otherwise bold headers silently fall back to regular.
Making It Cheap
A render costs roughly 25–45ms of CPU. That is over the 10ms limit of Cloudflare’s free Workers plan, and more than anyone wants to spend each time a crawler visits.
Shares are immutable snapshots, so the image for a share never changes. The PNG is served with Cache-Control: public, max-age=31536000, immutable and stored in the Cloudflare cache on first render. Each share is rendered once per data centre. After that, crawlers get a cached file.
The one thing that can change is the card design. The share page links the image as /share/:id/og.png?v=2; bumping the version gives every share a new URL, which sidesteps both the edge cache and the platforms’ own caches. That matters because Slack, LinkedIn and X all cache unfurls aggressively and give you few ways to clear them.
If rendering fails, the endpoint returns the generic site image with a short cache lifetime, so a crawler still gets a picture.
A few small details:
X-Robots-Tag: noindex. Share pages are meant to be unfurled, not indexed._headersrules don’t apply to Function responses, so the header is set in code.- The canonical
Linkheader is removed. The homepage asset carries one, and leaving it would tell crawlers that every share is the homepage. - Every interpolated value is escaped. File names are user-supplied and end up in both HTML attributes and SVG text.
Limits
The card is an approximation. Edges can pass behind tables the real diagram would route around, CJK table names don’t have glyphs yet, and a model with hundreds of tables becomes a texture rather than a diagram. For the models people actually share in a chat thread, it is enough to answer “what is this?” before anyone clicks.
Try it: share a model from pbix.info and paste the link anywhere.