code-snippet

Code snippet OG image template

A dark editor window with line numbers, syntax colours and a file tab, on a background in your accent colour.

Code snippet Open Graph image template rendered by Shareglint
Code snippet template at square size (1080×1080)
Code snippet template at portrait size (1080×1350)
Code snippet template at story size (1080×1920)
Code snippet template at pinterest size (1000×1500)
Code snippet template at youtube size (1280×720)

These are real renders from the API with the example values in the table below. Switch the size above: the same template lays itself out for all 6 sizes — send size or sizes with the request.

For tips, tutorials and launch posts that show the code. Send the code with real line breaks; strings, comments, numbers and common keywords get colours, long lines wrap with their line number kept, and the whole block shrinks when it is long. The first 16 lines are shown.

Fields

Every field is optional. Long text shrinks to fit instead of overflowing; an image field takes a public URL that we fetch on our side.

Field Type Description Example
code text The code, with line breaks. Up to 16 lines are shown. default: console.log('Hello, world') import { render } from '@northwind/og-kit' // One template, every size const images = await render({ template: 'blog-og', sizes: ['og', 'square', 'story'], title: 'Ship faster with signed URLs', }) console.log(images.length) // 3
title text Headline above the editor. Render every social size in one call
filename text File name on the editor tab. render.ts
language text Language label in the editor bar, e.g. TypeScript. TypeScript
author text Author or handle next to the title. @mayacodes
site text Your domain or a short URL. northwind.dev/blog
accent colour Brand colour as hex, e.g. #6366f1. Drives buttons, highlights and the background glow. default: #6366f1 #6366f1
theme dark | light Colour scheme: dark or light. —

Render it with one request

Use the slug as template. The response holds the URL of the finished PNG; ?wait=true keeps the connection open until it is ready.

curl -X POST "https://shareglint.com/v1/images?wait=true" \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "code-snippet",
    "modifications": {
        "code": "import { render } from '\''@northwind/og-kit'\''\n\n// One template, every size\nconst images = await render({\n  template: '\''blog-og'\'',\n  sizes: ['\''og'\'', '\''square'\'', '\''story'\''],\n  title: '\''Ship faster with signed URLs'\'',\n})\n\nconsole.log(images.length) // 3",
        "title": "Render every social size in one call",
        "filename": "render.ts",
        "language": "TypeScript",
        "author": "@mayacodes",
        "site": "northwind.dev/blog"
    }
}'

Or paste a signed URL into og:image

For static sites, Webflow, Shopify and no-code tools: put the fields in the query string and sign it with your signing secret. The first request renders the image, every later one is a redirect to the cached file. How to compute the signature.

<meta property="og:image" content="https://shareglint.com/i/acc_YOUR_ACCOUNT_ID/code-snippet.png?author=%40mayacodes&code=import%20%7B%20render%20%7D%20from%20%27%40northwind%2Fog-kit%27%0A%0A%2F%2F%20One%20template%2C%20every%20size%0Aconst%20images%20%3D%20await%20render%28%7B%0A%20%20template%3A%20%27blog-og%27%2C%0A%20%20sizes%3A%20%5B%27og%27%2C%20%27square%27%2C%20%27story%27%5D%2C%0A%20%20title%3A%20%27Ship%20faster%20with%20signed%20URLs%27%2C%0A%7D%29%0A%0Aconsole.log%28images.length%29%20%2F%2F%203&filename=render.ts&language=TypeScript&site=northwind.dev%2Fblog&title=Render%20every%20social%20size%20in%20one%20call&s=YOUR_SIGNATURE">

Make it yours

accent and theme change per request. For anything more, copy the template into your account: you get an ordinary HTML template with the same fields that you can edit in the dashboard or through the API. If the slug is free on your account, the copy takes it — your integrations switch to your version without changing a line.

curl -X POST "https://shareglint.com/v1/templates/library/code-snippet/copy" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"

More OG image templates

All templates →