image by vercel-labs/json-render
npx skills add https://github.com/vercel-labs/json-render --skill image使用 Satori 将 JSON 规范转换为 SVG 和 PNG 图像的图像渲染器。
import { renderToPng } from "@json-render/image/render";
import type { Spec } from "@json-render/core";
const spec: Spec = {
root: "frame",
elements: {
frame: {
type: "Frame",
props: { width: 1200, height: 630, backgroundColor: "#1a1a2e" },
children: ["heading"],
},
heading: {
type: "Heading",
props: { text: "Hello World", level: "h1", color: "#ffffff" },
children: [],
},
},
};
const png = await renderToPng(spec, {
fonts: [{ name: "Inter", data: fontData, weight: 400, style: "normal" }],
});
import { defineCatalog } from "@json-render/core";
import { schema, standardComponentDefinitions } from "@json-render/image";
export const imageCatalog = defineCatalog(schema, {
components: standardComponentDefinitions,
});
import { z } from "zod";
const catalog = defineCatalog(schema, {
components: {
...standardComponentDefinitions,
Badge: {
props: z.object({ label: z.string(), color: z.string().nullable() }),
slots: [],
description: "A colored badge label",
},
},
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 组件 | 类别 | 描述 |
|---|---|---|
Frame | 根容器 | 根容器。定义宽度、高度、背景。必须是根元素。 |
Box | 布局 | 具有内边距、外边距、边框、绝对定位的容器 |
Row | 布局 | 水平弹性布局 |
Column | 布局 | 垂直弹性布局 |
Heading | 内容 | h1-h4 标题文本 |
Text | 内容 | 具有完整样式的正文文本 |
Image | 内容 | 来自 URL 的图像 |
Divider | 装饰 | 水平分隔线 |
Spacer | 装饰 | 垂直空白空间 |
| 导出项 | 用途 |
|---|---|
renderToSvg | 将规范渲染为 SVG 字符串 |
renderToPng | 将规范渲染为 PNG 缓冲区(需要 @resvg/resvg-js) |
schema | 图像元素模式 |
standardComponents | 预构建的组件注册表 |
standardComponentDefinitions | 用于 AI 提示的目录定义 |
| 导出项 | 描述 |
|---|---|
@json-render/image | 完整包:模式、组件、渲染函数 |
@json-render/image/server | 仅模式和目录定义(无 React/Satori) |
@json-render/image/catalog | 标准组件定义和类型 |
@json-render/image/render | 仅渲染函数 |
每周安装量
226
代码仓库
GitHub 星标数
13.3K
首次出现
2026年3月7日
安全审计
安装于
codex221
cursor218
opencode218
kimi-cli217
amp217
cline217
Image renderer that converts JSON specs into SVG and PNG images using Satori.
import { renderToPng } from "@json-render/image/render";
import type { Spec } from "@json-render/core";
const spec: Spec = {
root: "frame",
elements: {
frame: {
type: "Frame",
props: { width: 1200, height: 630, backgroundColor: "#1a1a2e" },
children: ["heading"],
},
heading: {
type: "Heading",
props: { text: "Hello World", level: "h1", color: "#ffffff" },
children: [],
},
},
};
const png = await renderToPng(spec, {
fonts: [{ name: "Inter", data: fontData, weight: 400, style: "normal" }],
});
import { defineCatalog } from "@json-render/core";
import { schema, standardComponentDefinitions } from "@json-render/image";
export const imageCatalog = defineCatalog(schema, {
components: standardComponentDefinitions,
});
import { z } from "zod";
const catalog = defineCatalog(schema, {
components: {
...standardComponentDefinitions,
Badge: {
props: z.object({ label: z.string(), color: z.string().nullable() }),
slots: [],
description: "A colored badge label",
},
},
});
| Component | Category | Description |
|---|---|---|
Frame | Root | Root container. Defines width, height, background. Must be root. |
Box | Layout | Container with padding, margin, border, absolute positioning |
Row | Layout | Horizontal flex layout |
Column | Layout | Vertical flex layout |
Heading | Content | h1-h4 heading text |
| Export | Purpose |
|---|---|
renderToSvg | Render spec to SVG string |
renderToPng | Render spec to PNG buffer (requires @resvg/resvg-js) |
schema | Image element schema |
standardComponents | Pre-built component registry |
standardComponentDefinitions | Catalog definitions for AI prompts |
| Export | Description |
|---|---|
@json-render/image | Full package: schema, components, render functions |
@json-render/image/server | Schema and catalog definitions only (no React/Satori) |
@json-render/image/catalog | Standard component definitions and types |
@json-render/image/render | Render functions only |
Weekly Installs
226
Repository
GitHub Stars
13.3K
First Seen
Mar 7, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex221
cursor218
opencode218
kimi-cli217
amp217
cline217
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
109,600 周安装
Text | Content | Body text with full styling |
Image | Content | Image from URL |
Divider | Decorative | Horizontal line separator |
Spacer | Decorative | Empty vertical space |