# Add Social Cards to a VitePress Blog

Yes. An agent renders a preview image per post at build time, adds og:image and twitter tags to each page's head, and opens a PR with the cards attached.

[Run this on Rush](https://cloud.getrush.ai/run/add-social-cards/vitepress/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts from what a shared link shows today. In a VitePress blog laid out like vuejs/blog, `.vitepress/config.ts` sets three site-wide meta tags in `head`: `twitter:site`, `twitter:card` as `summary`, and `twitter:image` pointing at the Vue logo, so every post shares one small card with the same logo and no title. There is no `og:title`, `og:description`, `og:image` or `og:type` anywhere, and the only build hook is `buildEnd: genFeed`. `.vitepress/genFeed.ts` already loads every post with `createContentLoader('posts/*.md', { excerpt: true, render: true })`, sorts by `frontmatter.date` and writes `feed.rss` into `config.outDir`, which is the pattern the cards follow. `.vitepress/theme/posts.data.ts` reads the same frontmatter for the index, and each post under `posts/` carries `title`, `date`, `author`, `gravatar` and `twitter`.

Then it reads the theme and the toolchain. `package.json` pins `vitepress ^1.3.4`, `vue`, `feed`, `gray-matter`, Tailwind with `@tailwindcss/typography` and `packageManager: pnpm@9.8.0`; `postcss.config.js` scopes Tailwind to `.vitepress/theme/**/*.vue`; `.vitepress/theme/Layout.vue` draws the header with `/logo.svg` and `Article.vue` renders the title, `Date.vue` and `Author.vue`; `vercel.json` has `cleanUrls` and an immutable cache header for `/assets/*`; `.gitignore` ignores `dist` and `.vitepress/cache`. Post URLs are `/posts/<slug>` with the slug taken from the file name, which is what the card file names use.

The agent adds `.vitepress/genOgImages.ts`, called from `buildEnd` after `genFeed`. For each post it draws a card with `satori` from a small element tree, the post title in large type, the author's name and the formatted date, the Vue logo in a corner and the site's brand green from `theme/style.css`, with a font file committed under `.vitepress/fonts/` because satori needs font data rather than a CSS font name. `@resvg/resvg-js` rasterises the SVG to a PNG written at `og/<slug>.png` in `config.outDir`, beside `feed.rss`. Both packages go in `devDependencies` through `pnpm add -D`, so `pnpm-lock.yaml` changes with them. For the tags, `transformPageData` in `config.ts` appends to each post's `frontmatter.head`: `og:type` article, `og:title`, `og:description` from the excerpt with its HTML stripped, `og:url` and `og:image` as absolute URLs under the site origin `genFeed.ts` already names, `twitter:card` as `summary_large_image` and `twitter:image` matching `og:image`. The site-wide `twitter:card` and `twitter:image` move out of `head` so the home page gets its own logo card through the same hook rather than two competing values.

To prove it, the agent runs `pnpm install` and `pnpm build` in its sandbox, lists `dist/og/` to show one PNG per post, attaches two of them as files on the run so a reviewer sees the real card, and greps `dist/posts/<slug>.html` for the `og:image` and `twitter:card` lines. It also runs `pnpm preview` and fetches one post's HTML and its card to show both resolve. It changes no post, no Vue component and nothing under `public/`.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add generated social cards to this VitePress blog. Read package.json, .vitepress/config.ts, .vitepress/genFeed.ts, .vitepress/theme/posts.data.ts, .vitepress/theme/Layout.vue, .vitepress/theme/Article.vue, .vitepress/theme/style.css, vercel.json and two files under posts/ first. Add .vitepress/genOgImages.ts, run from buildEnd after genFeed, that loads the posts with createContentLoader the way genFeed does and renders one PNG per post with satori and @resvg/resvg-js, showing the title, author and date with the site logo and brand colour, using a font file you commit under .vitepress/fonts/; write each card to og/<slug>.png in config.outDir. In config.ts add transformPageData that sets og:type, og:title, og:description from the stripped excerpt, og:url, og:image, twitter:card summary_large_image and twitter:image on each post, and give the home page a logo card the same way; remove the site-wide twitter:card and twitter:image from head. Add the two packages with pnpm add -D. Run pnpm build, list dist/og, attach two cards as files, and paste the og and twitter meta lines from one built post. Change no post and no Vue component.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request adds `.vitepress/genOgImages.ts` and a font file under `.vitepress/fonts/`, changes `.vitepress/config.ts`, `package.json` and `pnpm-lock.yaml`, and touches nothing under `posts/` or `.vitepress/theme/`. Its description shows the `dist/og/` listing with one file per post, the meta tags from one built post, and links the two card images attached to the run so a reviewer sees the layout without building.

Every post now carries its own `og:image` and a `summary_large_image` card, and the home page keeps a logo card through the same hook instead of the old site-wide tags. The build is the only place the cards exist: nothing is committed under `public/`, and `.gitignore` already covers `dist`. The cards regenerate on every deploy, so a renamed title or a new author appears on the next build with no further step.

Before merging, a reviewer looks at the two attached cards for type size and contrast, confirms the font's licence allows bundling, and decides whether `vercel.json` should give `/og/*` a cache header like the one `/assets/*` has.

## Run it on every Linear issue labelled design

Add an automation to the Project with this prompt and a `linear` trigger on `linear.issue.labeled` with the label your design work uses in its `labels`. Each labelled issue starts one run with the issue as its context, on its own branch; the trigger adds the issue after the prompt and fills in no placeholder, and a change made by an app integration never fires it, so the agent's own comment on the issue starts nothing.

The automation's `max_runs_per_hour` holds a burst of labels to that many runs an hour: a fire past it is created `queued` and starts when the hour has room, and one past a second hour's worth is skipped as `rate_limited` until the issue is labelled again. From your own server, the same run starts with this request and the issue URL in `resources`, with a `request_id` that is a UUID v5 of the issue id so a retried start returns the run already begun.

## Why run it on Rush?

A social card is judged by looking at it, and the tags are judged by what a crawler fetches, so the proof is a built site, not a config diff. The agent builds in its own sandbox, attaches the real PNGs to the run and quotes the built HTML, so the reviewer sees the card a shared link will show before anything merges.

The transcript keeps `pnpm build`, the `dist/og/` listing and the preview fetches with their output, so the review happens from one page. Several VitePress sites can get cards at once, each run in its own sandbox with its own install, and nothing merges until a person reads the diff.

## Frequently asked questions

### Why render at build time instead of a Vercel OG endpoint?

The blog is a static VitePress build deployed as files, and the feed is already produced the same way in `buildEnd`. A build-time PNG needs no runtime, no edge function and no extra route, and it is versioned with the content: when a post changes, the next build rewrites its card.

### Will the cards work for Slack and other scrapers, not only Twitter?

Yes. `og:image`, `og:title` and `og:description` are what Slack, Discord, LinkedIn and most chat apps read; the `twitter:` tags only tell X to show the large layout. The agent sets both, with absolute URLs, since scrapers do not resolve relative ones.

### Why commit a font file?

satori lays out text itself and needs the glyph data, so it takes a font buffer rather than a CSS family name. One font file under `.vitepress/fonts/` keeps the build offline and deterministic; the pull request names the font and its licence so a reviewer can swap it.

### Does this slow the build down?

It adds one SVG layout and one rasterisation per post after the site is built, in the same hook that writes the feed. The pull request shows the `pnpm build` timing line as printed, before and after, so the reviewer sees the actual cost rather than an estimate.

## More VitePress jobs

- [Add Structured Data to a VitePress Blog](https://getrush.ai/run/add-structured-data/vitepress/)
- [Add a Typo Check to a VitePress Site in CI](https://getrush.ai/run/add-typo-check/vitepress/)
- [Add Versioned Docs to a VitePress Site](https://getrush.ai/run/add-versioned-docs/vitepress/)

## The same job on other stacks

- [Add Social Cards to an Eleventy Blog](https://getrush.ai/run/add-social-cards/eleventy/)
- [Add Social Card Images to a Gatsby Blog](https://getrush.ai/run/add-social-cards/gatsby/)
- [Add Social Cards to a Hugo Site](https://getrush.ai/run/add-social-cards/hugo/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
