@devries-cameron20 / composio Mirror · read-only / commits / 84c04f888
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 12:15 UTC

feat(docs): redesign social preview cards

Rebuild the /api/og route around a shared shell with a slot per section (docs, toolkits, API reference, changelog, home) on the docs dark surface, with a light variant behind theme=light. - Geist Sans / Mono vendored as TTF (Satori cannot read the site's woff2) - Composio wordmark and mark sliced from the existing logo SVGs - toolkit cards link the Composio mark to the toolkit logo; logos only load from Composio hosts and use the CDN's dark variant - reference cards show a REST API pill and version; changelog cards show the date once as an eyebrow - home card counts apps from the live catalog label - balanced title and description wrapping, faded pixel-grid background - assets traced for the build via outputFileTracingIncludes Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Malay Vasa committed Sep 16, 2026 at 19:30 UTC 84c04f888bdac8924b338f6bcfa546e4e865712f
15 files changed +591 -90
docs/app/(home)/docs/changelog/[...slug]/page.tsx
+7 -1
@@ -105,7 +105,13 @@ export async function generateMetadata({ params }: PageProps) {
105 : `Changelog - ${formatDate(dateStr)}`;
106
107 const description = `Updates from ${formatDate(dateStr)}`;
108 - const ogImage = getOgImageUrl('docs', ['changelog', ...slug], title, description);
108 + // The card shows the date as an eyebrow, so its title must not repeat it.
109 + const ogTitle = matchingEntries.length === 1
110 + ? matchingEntries[0].title
111 + : `${matchingEntries.length} updates`;
112 + const ogImage = getOgImageUrl('docs', ['changelog', ...slug], ogTitle, description, {
113 + date: formatDate(dateStr),
114 + });
115
116 return {
117 title: `${title} | Composio Changelog`,
docs/app/(home)/reference/(v31)/[[...slug]]/page.tsx
+5 -2
@@ -87,7 +87,8 @@ export async function generateMetadata({
87 'reference',
88 [],
89 'API Reference',
90 - 'REST API and SDK reference for Composio'
90 + 'REST API and SDK reference for Composio',
91 + { version: 'v3.1' }
92 );
93 return {
94 title: 'API Reference',
@@ -103,7 +104,9 @@ export async function generateMetadata({
104 if (!page) notFound();
105
106 const description = page.data.description || page.data.title;
106 - const ogImage = getOgImageUrl('reference', page.slugs, page.data.title, description);
107 + const ogImage = getOgImageUrl('reference', page.slugs, page.data.title, description, {
108 + version: 'v3.1',
109 + });
110
111 return {
112 title: page.data.title,
docs/app/(home)/reference/v3/[[...slug]]/page.tsx
+5 -2
@@ -96,7 +96,8 @@ export async function generateMetadata({
96 'reference',
97 [],
98 'API Reference (v3)',
99 - 'REST API reference for Composio v3'
99 + 'REST API reference for Composio v3',
100 + { version: 'v3' }
101 );
102 return {
103 title: 'API Reference (v3)',
@@ -112,7 +113,9 @@ export async function generateMetadata({
113 if (!page) notFound();
114
115 const description = page.data.description || page.data.title;
115 - const ogImage = getOgImageUrl('reference', page.slugs, page.data.title, description);
116 + const ogImage = getOgImageUrl('reference', page.slugs, page.data.title, description, {
117 + version: 'v3',
118 + });
119
120 return {
121 title: page.data.title,
docs/app/(home)/toolkits/[[...slug]]/page.tsx
+3 -1
@@ -185,7 +185,9 @@ export async function generateMetadata({
185 if (toolkit) {
186 const title = `${toolkit.name?.trim() || toolkit.slug} - Composio Toolkit`;
187 const description = `Build an AI agent that connects to ${toolkit.name?.trim() || toolkit.slug} using Composio. ${toolkit.description}`;
188 - const ogImage = getOgImageUrl('toolkits', slug, title, description);
188 + const ogImage = getOgImageUrl('toolkits', slug, title, description, {
189 + logo: toolkit.logo,
190 + });
191 return {
192 title,
193 description,
docs/app/api/og/route.tsx
+377 -59
@@ -1,73 +1,391 @@
1 +/* oxlint-disable next/no-img-element -- Satori renders raw <img>, next/image does not apply here */
2 import { ImageResponse } from 'next/og';
3 +import { readFile } from 'fs/promises';
4 +import { join } from 'path';
5
3 -export function GET(request: Request) {
6 +// Social preview cards for every docs page. One shared shell, one slot per
7 +// section. Palette and type follow app/global.css: dark DEV surface by
8 +// default, light on request, deep electric blue brand accent, square corners.
9 +// Geist Sans / Mono are vendored in app/fonts because Satori cannot read the
10 +// site's woff2 files.
11 +
12 +export const OG_WIDTH = 1200;
13 +export const OG_HEIGHT = 630;
14 +
15 +const THEMES = {
16 + dark: {
17 + ground: '#0f0f0f',
18 + card: '#1a1a1a',
19 + ink: '#fafafa',
20 + soft: '#d4d4d4',
21 + muted: '#a1a1a1',
22 + line: '#2a2a2a',
23 + brand: '#51a2ff',
24 + wordmarkFile: 'Composio Logo Dark.svg',
25 + logoTheme: 'dark',
26 + backgroundFile: 'og/bg-dark.jpg' as string | null,
27 + },
28 + light: {
29 + ground: '#fbfbfb',
30 + card: '#ffffff',
31 + ink: '#0f0f0f',
32 + soft: '#3d3d3d',
33 + muted: '#6b6b6b',
34 + line: '#e5e5e5',
35 + brand: '#0007cd',
36 + wordmarkFile: 'Composio Logo.svg',
37 + logoTheme: null,
38 + backgroundFile: null as string | null,
39 + },
40 +} as const;
41 +export type OgTheme = keyof typeof THEMES;
42 +type Palette = (typeof THEMES)[OgTheme];
43 +
44 +const SECTIONS = ['docs', 'toolkits', 'reference', 'changelog', 'home'] as const;
45 +export type OgSection = (typeof SECTIONS)[number];
46 +
47 +const SECTION_LABELS: Record<OgSection, string> = {
48 + docs: 'Docs',
49 + toolkits: 'Toolkits',
50 + reference: 'API Reference',
51 + changelog: 'Changelog',
52 + home: 'Docs',
53 +};
54 +
55 +const LOGO_HOSTS = new Set(['logos.composio.dev', 'assets.composio.dev']);
56 +
57 +const TITLE_MAX = 120;
58 +const DESCRIPTION_MAX = 200;
59 +
60 +// --- assets -----------------------------------------------------------------
61 +
62 +// Resolved per call, not at import time, so the app root is whatever cwd is
63 +// when the first request lands (matches lib/toolkit-data.ts).
64 +const fontsDir = () => join(process.cwd(), 'app/fonts');
65 +const publicDir = () => join(process.cwd(), 'public');
66 +
67 +type FontSpec = { name: string; data: ArrayBuffer; weight: 400 | 500; style: 'normal' };
68 +
69 +async function loadFont(file: string, name: string, weight: 400 | 500): Promise<FontSpec | null> {
70 + try {
71 + const buf = await readFile(join(fontsDir(), file));
72 + return { name, data: buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength), weight, style: 'normal' };
73 + } catch {
74 + return null;
75 + }
76 +}
77 +
78 +let fontsPromise: Promise<FontSpec[]> | null = null;
79 +function getFonts(): Promise<FontSpec[]> {
80 + if (!fontsPromise) {
81 + fontsPromise = Promise.all([
82 + loadFont('Geist-Regular.ttf', 'Geist', 400),
83 + loadFont('Geist-Medium.ttf', 'Geist', 500),
84 + loadFont('GeistMono-Regular.ttf', 'Geist Mono', 400),
85 + loadFont('GeistMono-Medium.ttf', 'Geist Mono', 500),
86 + ]).then((fonts) => fonts.filter((f): f is FontSpec => f !== null));
87 + }
88 + return fontsPromise;
89 +}
90 +
91 +interface Brand {
92 + /** Full wordmark as a data URI. */
93 + wordmark: string | null;
94 + /** Icon glyph only, as a data URI. */
95 + mark: string | null;
96 + /** Full-bleed background as a data URI, when the theme has one. */
97 + background: string | null;
98 +}
99 +
100 +const toDataUri = (svg: string) => `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}`;
101 +
102 +const brandPromises: Partial<Record<OgTheme, Promise<Brand>>> = {};
103 +function getBrand(theme: OgTheme): Promise<Brand> {
104 + let promise = brandPromises[theme];
105 + if (!promise) {
106 + const { wordmarkFile, backgroundFile } = THEMES[theme];
107 + const background = backgroundFile
108 + ? readFile(join(publicDir(), backgroundFile))
109 + .then((buf) => `data:image/jpeg;base64,${buf.toString('base64')}`)
110 + .catch(() => null)
111 + : Promise.resolve(null);
112 + promise = Promise.all([readFile(join(publicDir(), wordmarkFile), 'utf8').catch(() => null), background])
113 + .then(([svg, background]) => {
114 + if (!svg) return { wordmark: null, mark: null, background };
115 + // The first two <path>s of the wordmark are the icon glyph; the rest are letterforms.
116 + const paths = svg.match(/<path[^>]*\/>/g)?.slice(0, 2) ?? [];
117 + const mark = paths.length === 2
118 + ? toDataUri(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 104 121" fill="none">${paths.join('')}</svg>`)
119 + : null;
120 + return { wordmark: toDataUri(svg), mark, background };
121 + });
122 + brandPromises[theme] = promise;
123 + }
124 + return promise;
125 +}
126 +
127 +// --- params -----------------------------------------------------------------
128 +
129 +export interface OgParams {
130 + section: OgSection;
131 + theme: OgTheme;
132 + title: string;
133 + description: string;
134 + logo: string | null;
135 + date: string | null;
136 + version: string | null;
137 +}
138 +
139 +function clip(value: string | null, max: number): string {
140 + return Array.from((value ?? '').trim()).slice(0, max).join('');
141 +}
142 +
143 +function safeLogo(value: string | null, theme: OgTheme): string | null {
144 + if (!value) return null;
145 + try {
146 + const url = new URL(value);
147 + if (url.protocol !== 'https:' || !LOGO_HOSTS.has(url.hostname)) return null;
148 + const logoTheme = THEMES[theme].logoTheme;
149 + if (logoTheme) url.searchParams.set('theme', logoTheme);
150 + return url.toString();
151 + } catch {
152 + return null;
153 + }
154 +}
155 +
156 +export function parseOgParams(request: Request): OgParams {
157 const params = new URL(request.url).searchParams;
5 - const input = params.get('title')?.trim();
6 - const title = Array.from(input || 'Composio Docs').slice(0, 120).join('');
158 + const rawSection = params.get('section') ?? (params.get('variant') === 'home' ? 'home' : 'docs');
159 + const section = (SECTIONS as readonly string[]).includes(rawSection) ? (rawSection as OgSection) : 'docs';
160 + const theme: OgTheme = params.get('theme') === 'light' ? 'light' : 'dark';
161 + const title = clip(params.get('title'), TITLE_MAX) || (section === 'home' ? '' : 'Composio Docs');
162 + return {
163 + section,
164 + theme,
165 + title,
166 + description: clip(params.get('description'), DESCRIPTION_MAX),
167 + logo: safeLogo(params.get('logo'), theme),
168 + date: clip(params.get('date'), 40) || null,
169 + version: clip(params.get('version'), 12) || null,
170 + };
171 +}
172 +
173 +// --- primitives -------------------------------------------------------------
174 +
175 +const sans = 'Geist, ui-sans-serif, system-ui, sans-serif';
176 +const mono = '"Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace';
177 +
178 +interface Ctx {
179 + c: Palette;
180 + brand: Brand;
181 +}
182 +
183 +function Stack({ children, gap = 24 }: { children: React.ReactNode; gap?: number }) {
184 + // Satori flattens fragments into the parent's flex row, so every card
185 + // slot wraps its pieces in an explicit column.
186 + return <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', textAlign: 'center', gap }}>{children}</div>;
187 +}
188 +
189 +function Eyebrow({ children, color }: { children: string; color: string }) {
190 + return (
191 + <div style={{ display: 'flex', fontFamily: mono, fontSize: 20, fontWeight: 500, letterSpacing: 2.4, textTransform: 'uppercase', color }}>
192 + {children}
193 + </div>
194 + );
195 +}
196 +
197 +function Chip({ children, c }: { children: string; c: Palette }) {
198 + return (
199 + <div style={{
200 + display: 'flex', alignItems: 'center', padding: '8px 14px',
201 + border: `1px solid ${c.line}`, background: c.card,
202 + fontFamily: mono, fontSize: 18, letterSpacing: 1.2, textTransform: 'uppercase', color: c.muted,
203 + }}>
204 + {children}
205 + </div>
206 + );
207 +}
208 +
209 +function Title({ children, size, c }: { children: string; size: number; c: Palette }) {
210 + return (
211 + <div style={{
212 + display: 'flex', fontFamily: sans, fontWeight: 500, fontSize: size, lineHeight: 1.08,
213 + letterSpacing: size >= 60 ? -2 : -1.2, color: c.ink, maxWidth: 1000, lineClamp: 3,
214 + justifyContent: 'center', textAlign: 'center', textWrap: 'balance',
215 + }}>
216 + {children}
217 + </div>
218 + );
219 +}
220 +
221 +function titleSize(title: string, base = 72): number {
222 + const n = title.length;
223 + if (n > 90) return base - 28;
224 + if (n > 60) return base - 16;
225 + if (n > 36) return base - 8;
226 + return base;
227 +}
228 +
229 +function Description({ children, c }: { children: string; c: Palette }) {
230 + if (!children) return null;
231 + return (
232 + <div style={{
233 + display: 'flex', fontFamily: sans, fontSize: 30, lineHeight: 1.4, color: c.soft, maxWidth: 900, lineClamp: 2,
234 + justifyContent: 'center', textAlign: 'center', textWrap: 'balance',
235 + }}>
236 + {children}
237 + </div>
238 + );
239 +}
240 +
241 +function Node({ children, c }: { children: React.ReactNode; c: Palette }) {
242 + return (
243 + <div style={{
244 + display: 'flex', alignItems: 'center', justifyContent: 'center',
245 + width: 112, height: 112, background: c.card, border: `1px solid ${c.line}`,
246 + }}>
247 + {children}
248 + </div>
249 + );
250 +}
251 +
252 +// --- shell ------------------------------------------------------------------
253 +
254 +function Shell({ ctx, label, children }: { ctx: Ctx; label: string; children: React.ReactNode }) {
255 + const { c, brand } = ctx;
256 + return (
257 + <div style={{
258 + display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
259 + width: '100%', height: '100%', padding: '56px 64px',
260 + background: c.ground, color: c.ink, fontFamily: sans, position: 'relative',
261 + }}>
262 + {brand.background ? (
263 + <img src={brand.background} width={OG_WIDTH} height={OG_HEIGHT} alt=""
264 + style={{ position: 'absolute', top: 0, left: 0, width: OG_WIDTH, height: OG_HEIGHT, opacity: 0.7 }} />
265 + ) : null}
266 + <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
267 + {brand.wordmark ? (
268 + <img src={brand.wordmark} width={165} height={30} alt="" />
269 + ) : (
270 + <div style={{ display: 'flex', fontSize: 28, fontWeight: 500 }}>Composio</div>
271 + )}
272 + <Eyebrow color={c.brand}>{label}</Eyebrow>
273 + </div>
274
8 - return new ImageResponse(
9 - params.get('variant') === 'home' ? (
275 <div style={{
11 - display: 'flex', width: '100%', height: '100%',
12 - background: '#131211', color: '#faf9f6', fontFamily: 'sans-serif',
276 + display: 'flex', flexDirection: 'column', gap: 24, flexGrow: 1,
277 + justifyContent: 'center', alignItems: 'center', textAlign: 'center', paddingTop: 24,
278 }}>
14 - <div style={{
15 - display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
16 - width: 810, padding: '60px 64px',
17 - }}>
18 - <div style={{ display: 'flex', alignItems: 'center', gap: 16, fontSize: 28 }}>
19 - <div style={{ width: 24, height: 24, background: '#f76b15', borderRadius: 5 }} />
20 - Composio Docs
21 - </div>
22 - <div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
23 - <div style={{ display: 'flex', flexDirection: 'column', fontSize: 76, lineHeight: 1.04, letterSpacing: -3 }}>
24 - <span>Build and operate</span>
25 - <span style={{ color: '#ff8a42' }}>AI agents.</span>
26 - </div>
27 - <div style={{ display: 'flex', fontSize: 27, lineHeight: 1.4, color: '#bbb7b0', maxWidth: 620 }}>
28 - Tools, managed authentication, and secure execution for your agents.
29 - </div>
30 - </div>
31 - <div style={{ display: 'flex', fontSize: 23, color: '#bbb7b0' }}>docs.composio.dev</div>
279 + {children}
280 + </div>
281 + </div>
282 + );
283 +}
284 +
285 +// --- section slots ----------------------------------------------------------
286 +
287 +type CardProps = { p: OgParams; ctx: Ctx };
288 +
289 +function DocsCard({ p, ctx: { c } }: CardProps) {
290 + return (
291 + <Stack>
292 + <Title size={titleSize(p.title)} c={c}>{p.title}</Title>
293 + <Description c={c}>{p.description}</Description>
294 + </Stack>
295 + );
296 +}
297 +
298 +function ToolkitCard({ p, ctx: { c, brand } }: CardProps) {
299 + const name = p.title.replace(/\s*-\s*Composio Toolkit\s*$/i, '');
300 + return (
301 + <Stack>
302 + {p.logo ? (
303 + <div style={{ display: 'flex', alignItems: 'center', marginBottom: 16 }}>
304 + <Node c={c}>
305 + {brand.mark ? <img src={brand.mark} width={56} height={65} alt="" /> : <div style={{ display: 'flex', fontSize: 40, fontWeight: 500 }}>C</div>}
306 + </Node>
307 + <div style={{ display: 'flex', width: 72, height: 4, background: c.muted }} />
308 + <Node c={c}>
309 + <img src={p.logo} width={72} height={72} alt="" style={{ objectFit: 'contain' }} />
310 + </Node>
311 </div>
312 + ) : null}
313 + <Title size={titleSize(`${name} Toolkit`, 64)} c={c}>{`${name} Toolkit`}</Title>
314 + <Description c={c}>{p.description || `Connect your AI agent to ${name} with Composio.`}</Description>
315 + </Stack>
316 + );
317 +}
318 +
319 +function ReferenceCard({ p, ctx: { c } }: CardProps) {
320 + return (
321 + <Stack>
322 + <div style={{ display: 'flex', justifyContent: 'center', gap: 10 }}>
323 <div style={{
34 - display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
35 - width: 390, padding: '64px 40px', background: '#f76b15', color: '#131211',
324 + display: 'flex', alignItems: 'center', padding: '8px 14px',
325 + background: c.brand, color: c.ground,
326 + fontFamily: mono, fontSize: 18, fontWeight: 500, letterSpacing: 1.2,
327 }}>
37 - <div style={{ display: 'flex', fontSize: 20, letterSpacing: 3 }}>FROM THE DOCS</div>
38 - <div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
39 - {['SDK', 'CLI', 'MCP'].map((label) => (
40 - <div key={label} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', borderBottom: '1px solid #b84c0b', paddingBottom: 20 }}>
41 - <span style={{ fontSize: 48 }}>{label}</span>
42 - <span style={{ fontSize: 32 }}>↗</span>
43 - </div>
44 - ))}
45 - </div>
46 - <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '18px 22px', borderRadius: 8, background: '#131211', color: '#faf9f6', fontSize: 26 }}>
47 - <span>Start building</span><span>→</span>
48 - </div>
328 + REST API
329 </div>
330 + {p.version ? <Chip c={c}>{p.version}</Chip> : null}
331 </div>
51 - ) : (
52 - <div style={{
53 - display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
54 - width: '100%', height: '100%', padding: 72, background: '#131211', color: '#faf9f6',
55 - fontFamily: 'sans-serif',
56 - }}>
57 - <div style={{ display: 'flex', alignItems: 'center', gap: 18, fontSize: 32 }}>
58 - <div style={{ width: 28, height: 28, background: '#f76b15', borderRadius: 6 }} />
59 - Composio Docs
60 - </div>
61 - <div style={{ display: 'flex', fontSize: title.length > 60 ? 48 : 68, lineHeight: 1.12,
62 - letterSpacing: -2, maxWidth: 1056, overflowWrap: 'break-word' }}>
63 - {title}
64 - </div>
65 - <div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 24, color: '#bbb7b0' }}>
66 - <span>Build and operate agents</span>
67 - <span>docs.composio.dev</span>
332 + <Title size={titleSize(p.title)} c={c}>{p.title}</Title>
333 + <Description c={c}>{p.description}</Description>
334 + </Stack>
335 + );
336 +}
337 +
338 +function ChangelogCard({ p, ctx: { c } }: CardProps) {
339 + return (
340 + <Stack>
341 + {p.date ? <Eyebrow color={c.muted}>{p.date}</Eyebrow> : null}
342 + <Title size={titleSize(p.title)} c={c}>{p.title}</Title>
343 + {/* The page description is "Updates from <date>", which the eyebrow already says. */}
344 + {p.date ? null : <Description c={c}>{p.description}</Description>}
345 + </Stack>
346 + );
347 +}
348 +
349 +function HomeCard({ p, ctx: { c } }: CardProps) {
350 + return (
351 + <Stack>
352 + <div style={{
353 + display: 'flex', flexDirection: 'column', alignItems: 'center',
354 + fontFamily: sans, fontWeight: 500, fontSize: 84, lineHeight: 1.02, letterSpacing: -3, color: c.ink,
355 + }}>
356 + <span>Build and operate</span>
357 + <span style={{ color: c.brand }}>AI agents.</span>
358 </div>
69 - </div>
70 - ),
71 - { width: 1200, height: 630, headers: { 'Cache-Control': 'public, max-age=86400' } },
359 + <Description c={c}>{p.description || 'Tools, managed authentication, and secure execution for your agents.'}</Description>
360 + </Stack>
361 + );
362 +}
363 +
364 +const CARDS: Record<OgSection, (props: CardProps) => React.ReactElement> = {
365 + docs: DocsCard,
366 + toolkits: ToolkitCard,
367 + reference: ReferenceCard,
368 + changelog: ChangelogCard,
369 + home: HomeCard,
370 +};
371 +
372 +// --- handler ----------------------------------------------------------------
373 +
374 +export async function GET(request: Request) {
375 + const p = parseOgParams(request);
376 + const [fonts, brand] = await Promise.all([getFonts(), getBrand(p.theme)]);
377 + const ctx: Ctx = { c: THEMES[p.theme], brand };
378 + const Card = CARDS[p.section];
379 +
380 + return new ImageResponse(
381 + <Shell ctx={ctx} label={SECTION_LABELS[p.section]}>
382 + <Card p={p} ctx={ctx} />
383 + </Shell>,
384 + {
385 + width: OG_WIDTH,
386 + height: OG_HEIGHT,
387 + fonts,
388 + headers: { 'Cache-Control': 'public, max-age=86400, s-maxage=86400' },
389 + },
390 );
391 }
docs/app/fonts/GEIST-LICENSE.txt new
+92
@@ -0,0 +1,92 @@
1 +Copyright (c) 2023 Vercel, in collaboration with basement.studio
2 +
3 +This Font Software is licensed under the SIL Open Font License, Version 1.1.
4 +This license is copied below, and is also available with a FAQ at:
5 +http://scripts.sil.org/OFL
6 +
7 +-----------------------------------------------------------
8 +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9 +-----------------------------------------------------------
10 +
11 +PREAMBLE
12 +The goals of the Open Font License (OFL) are to stimulate worldwide
13 +development of collaborative font projects, to support the font creation
14 +efforts of academic and linguistic communities, and to provide a free and
15 +open framework in which fonts may be shared and improved in partnership
16 +with others.
17 +
18 +The OFL allows the licensed fonts to be used, studied, modified and
19 +redistributed freely as long as they are not sold by themselves. The
20 +fonts, including any derivative works, can be bundled, embedded,
21 +redistributed and/or sold with any software provided that any reserved
22 +names are not used by derivative works. The fonts and derivatives,
23 +however, cannot be released under any other type of license. The
24 +requirement for fonts to remain under this license does not apply
25 +to any document created using the fonts or their derivatives.
26 +
27 +DEFINITIONS
28 +"Font Software" refers to the set of files released by the Copyright
29 +Holder(s) under this license and clearly marked as such. This may
30 +include source files, build scripts and documentation.
31 +
32 +"Reserved Font Name" refers to any names specified as such after the
33 +copyright statement(s).
34 +
35 +"Original Version" refers to the collection of Font Software components as
36 +distributed by the Copyright Holder(s).
37 +
38 +"Modified Version" refers to any derivative made by adding to, deleting,
39 +or substituting -- in part or in whole -- any of the components of the
40 +Original Version, by changing formats or by porting the Font Software to a
41 +new environment.
42 +
43 +"Author" refers to any designer, engineer, programmer, technical
44 +writer or other person who contributed to the Font Software.
45 +
46 +PERMISSION AND CONDITIONS
47 +Permission is hereby granted, free of charge, to any person obtaining
48 +a copy of the Font Software, to use, study, copy, merge, embed, modify,
49 +redistribute, and sell modified and unmodified copies of the Font
50 +Software, subject to the following conditions:
51 +
52 +1) Neither the Font Software nor any of its individual components,
53 +in Original or Modified Versions, may be sold by itself.
54 +
55 +2) Original or Modified Versions of the Font Software may be bundled,
56 +redistributed and/or sold with any software, provided that each copy
57 +contains the above copyright notice and this license. These can be
58 +included either as stand-alone text files, human-readable headers or
59 +in the appropriate machine-readable metadata fields within text or
60 +binary files as long as those fields can be easily viewed by the user.
61 +
62 +3) No Modified Version of the Font Software may use the Reserved Font
63 +Name(s) unless explicit written permission is granted by the corresponding
64 +Copyright Holder. This restriction only applies to the primary font name as
65 +presented to the users.
66 +
67 +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68 +Software shall not be used to promote, endorse or advertise any
69 +Modified Version, except to acknowledge the contribution(s) of the
70 +Copyright Holder(s) and the Author(s) or with their explicit written
71 +permission.
72 +
73 +5) The Font Software, modified or unmodified, in part or in whole,
74 +must be distributed entirely under this license, and must not be
75 +distributed under any other license. The requirement for fonts to
76 +remain under this license does not apply to any document created
77 +using the Font Software.
78 +
79 +TERMINATION
80 +This license becomes null and void if any of the above conditions are
81 +not met.
82 +
83 +DISCLAIMER
84 +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87 +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88 +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89 +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90 +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91 +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92 +OTHER DEALINGS IN THE FONT SOFTWARE.
docs/app/fonts/Geist-Medium.ttf
Binary files /dev/null and b/docs/app/fonts/Geist-Medium.ttf differ
docs/app/fonts/Geist-Regular.ttf
Binary files /dev/null and b/docs/app/fonts/Geist-Regular.ttf differ
docs/app/fonts/GeistMono-Medium.ttf
Binary files /dev/null and b/docs/app/fonts/GeistMono-Medium.ttf differ
docs/app/fonts/GeistMono-Regular.ttf
Binary files /dev/null and b/docs/app/fonts/GeistMono-Regular.ttf differ
docs/app/layout.tsx
+7 -3
@@ -8,7 +8,7 @@ import localFont from 'next/font/local';
8 import { PostHogProvider } from '@/components/posthog-provider';
9 import CustomSearchDialog from '@/components/custom-search-dialog';
10 import { ScrollReset } from '@/components/scroll-reset';
11 -import { source, referenceSource } from '@/lib/source';
11 +import { source, referenceSource, getOgImageUrl } from '@/lib/source';
12 import { TOOLKIT_COUNT_LABEL } from '@/lib/toolkit-count';
13 import { ProductTransitionLoader } from '@/components/product-transition-loader';
14 import { DocsProductProvider } from '@/components/docs-product-context';
@@ -35,6 +35,10 @@ const defaultLinks = defaultLinkSlugs.flatMap(({ slug, source: pageSource }) =>
35 });
36
37 const SITE_DESCRIPTION = `Build AI agents with ${TOOLKIT_COUNT_LABEL} tools. Connect LLMs to external services like GitHub, Slack, Gmail, and more.`;
38 +// Social card copy for the docs homepage. Counts apps rather than tools so it
39 +// matches the wording on the landing page.
40 +const HOME_OG_DESCRIPTION = `Build AI agents with ${TOOLKIT_COUNT_LABEL} apps. Connect LLMs to external services like GitHub, Slack, Gmail, and more.`;
41 +const HOME_OG_IMAGE = getOgImageUrl('docs', [], 'Composio Docs', HOME_OG_DESCRIPTION);
42
43 export const metadata: Metadata = {
44 title: {
@@ -48,13 +52,13 @@ export const metadata: Metadata = {
52 description: SITE_DESCRIPTION,
53 siteName: 'Composio Docs',
54 type: 'website',
51 - images: ['https://docs.composio.dev/api/og?variant=home'],
55 + images: [HOME_OG_IMAGE],
56 },
57 twitter: {
58 card: 'summary_large_image',
59 title: 'Composio Docs',
60 description: SITE_DESCRIPTION,
57 - images: ['https://docs.composio.dev/api/og?variant=home'],
61 + images: [HOME_OG_IMAGE],
62 },
63 };
64
docs/lib/source.ts
+26 -4
@@ -160,17 +160,39 @@ export type ChangelogEntry = DocCollectionEntry<
160 // checker. Preserve the collection's public shape for all route consumers.
161 export const changelogEntries = changelog as ChangelogEntry[];
162
163 +export interface OgImageExtras {
164 + /** Toolkit logo URL. Only https://logos.composio.dev and https://assets.composio.dev are rendered. */
165 + logo?: string | null;
166 + /** Changelog date, already formatted for display. */
167 + date?: string | null;
168 + /** API reference version label, e.g. "v3.1". */
169 + version?: string | null;
170 +}
171 +
172 +const OG_ROUTE = 'https://docs.composio.dev/api/og';
173 +
174 export function getOgImageUrl(
175 section: string,
176 slugs: string[],
177 title?: string,
167 - _description?: string
178 + description?: string,
179 + extras: OgImageExtras = {}
180 ): string {
181 + const params = new URLSearchParams();
182 if (section === 'docs' && slugs.length === 0) {
170 - return 'https://docs.composio.dev/api/og?variant=home';
183 + params.set('section', 'home');
184 + if (description) params.set('description', description);
185 + return `${OG_ROUTE}?${params.toString()}`;
186 + }
187 + const isChangelog = section === 'docs' && slugs[0] === 'changelog';
188 + params.set('section', isChangelog ? 'changelog' : section);
189 + params.set('title', title ?? 'Composio Docs');
190 + if (description) params.set('description', description);
191 + for (const key of ['logo', 'date', 'version'] as const) {
192 + const value = extras[key];
193 + if (value) params.set(key, value);
194 }
172 - const encodedTitle = encodeURIComponent(title ?? 'Composio Docs');
173 - return `https://docs.composio.dev/api/og?title=${encodedTitle}`;
195 + return `${OG_ROUTE}?${params.toString()}`;
196 }
197
198 /**
docs/next.config.mjs
+2
@@ -44,6 +44,8 @@ const config = {
44 '/llms-index.txt/**': [...OPENAPI_SPEC_FILES, './kb/**'],
45 '/kb/**': ['./kb/**'],
46 '/api/knowledge-search/**': [...OPENAPI_SPEC_FILES, './content/**', './kb/**'],
47 + // The OG route reads its fonts and wordmark from disk at request time.
48 + '/api/og/**': ['./app/fonts/Geist*.ttf', './public/Composio Logo*.svg', './public/og/*'],
49 },
50 images: {
51 // Enable modern image formats for better compression
docs/public/og/bg-dark.jpg
Binary files /dev/null and b/docs/public/og/bg-dark.jpg differ
docs/tests/static/og-image.test.ts
+67 -18
@@ -1,29 +1,78 @@
1 import { expect, test } from 'bun:test';
2 -import { GET } from '../../app/api/og/route';
2 +import { GET, parseOgParams } from '../../app/api/og/route';
3 import { getOgImageUrl } from '../../lib/source';
4
5 +async function expectPng(url: string) {
6 + const response = await GET(new Request(url));
7 + expect(response.status).toBe(200);
8 + expect(response.headers.get('content-type')).toBe('image/png');
9 + const bytes = Buffer.from(await response.arrayBuffer());
10 + expect(bytes.subarray(1, 4).toString()).toBe('PNG');
11 + expect(bytes.readUInt32BE(16)).toBe(1200);
12 + expect(bytes.readUInt32BE(20)).toBe(630);
13 +}
14 +
15 test('docs host renders a PNG for the advertised title URL', async () => {
16 for (const title of ['Welcome', 'Authentication & OAuth / setup', 'Very long title '.repeat(20), '']) {
17 const url = getOgImageUrl('docs', ['authentication'], title);
18 expect(new URL(url).origin).toBe('https://docs.composio.dev');
9 - const response = GET(new Request(url));
10 - expect(response.status).toBe(200);
11 - expect(response.headers.get('content-type')).toBe('image/png');
12 - const bytes = Buffer.from(await response.arrayBuffer());
13 - expect(bytes.subarray(1, 4).toString()).toBe('PNG');
14 - expect(bytes.readUInt32BE(16)).toBe(1200);
15 - expect(bytes.readUInt32BE(20)).toBe(630);
19 + await expectPng(url);
20 }
21 });
22
19 -test('the docs homepage uses a distinct card without changing article cards', async () => {
20 - const url = getOgImageUrl('docs', [], 'Welcome');
21 - expect(new URL(url).searchParams.get('variant')).toBe('home');
22 - expect(new URL(getOgImageUrl('reference', [], 'API Reference')).searchParams.get('title')).toBe('API Reference');
23 - const response = GET(new Request(url));
24 - expect(response.headers.get('content-type')).toBe('image/png');
25 - const bytes = Buffer.from(await response.arrayBuffer());
26 - expect(bytes.subarray(1, 4).toString()).toBe('PNG');
27 - expect(bytes.readUInt32BE(16)).toBe(1200);
28 - expect(bytes.readUInt32BE(20)).toBe(630);
23 +test('every section renders its own card', async () => {
24 + await expectPng(getOgImageUrl('docs', [], 'Welcome', 'Site description'));
25 + await expectPng(getOgImageUrl('toolkits', ['zendesk'], 'Zendesk - Composio Toolkit', ''));
26 + await expectPng(getOgImageUrl('reference', ['connected-accounts'], 'Connected Accounts', 'Manage accounts', {
27 + version: 'v3.1',
28 + }));
29 + await expectPng(getOgImageUrl('docs', ['changelog', '2026', '09', '04'], 'September releases', 'Updates', {
30 + date: 'Sep 4, 2026',
31 + }));
32 +});
33 +
34 +test('the URL builder names the section and forwards extras', () => {
35 + const home = new URL(getOgImageUrl('docs', [], 'Welcome', 'desc'));
36 + expect(home.searchParams.get('section')).toBe('home');
37 + expect(home.searchParams.get('description')).toBe('desc');
38 +
39 + const changelog = new URL(getOgImageUrl('docs', ['changelog', '2026', '09', '04'], 'Title', 'Updates', { date: 'Sep 4, 2026' }));
40 + expect(changelog.searchParams.get('section')).toBe('changelog');
41 + expect(changelog.searchParams.get('date')).toBe('Sep 4, 2026');
42 +
43 + const toolkit = new URL(getOgImageUrl('toolkits', ['github'], 'GitHub - Composio Toolkit', 'desc', {
44 + logo: 'https://logos.composio.dev/api/github',
45 + }));
46 + expect(toolkit.searchParams.get('section')).toBe('toolkits');
47 + expect(toolkit.searchParams.get('logo')).toBe('https://logos.composio.dev/api/github');
48 +
49 + const reference = new URL(getOgImageUrl('reference', [], 'API Reference', 'desc', { version: 'v3.1' }));
50 + expect(reference.searchParams.get('version')).toBe('v3.1');
51 + expect(reference.searchParams.get('title')).toBe('API Reference');
52 +});
53 +
54 +test('the route only honors toolkit logos from Composio hosts', () => {
55 + const allowed = parseOgParams(new Request('https://docs.composio.dev/api/og?section=toolkits&logo=https%3A%2F%2Flogos.composio.dev%2Fapi%2Fgithub'));
56 + expect(allowed.logo).toBe('https://logos.composio.dev/api/github?theme=dark');
57 +
58 + for (const logo of ['https://evil.example/x.png', 'http://logos.composio.dev/api/github', 'not a url', 'data:image/png;base64,AAAA']) {
59 + const blocked = parseOgParams(new Request(`https://docs.composio.dev/api/og?section=toolkits&logo=${encodeURIComponent(logo)}`));
60 + expect(blocked.logo).toBeNull();
61 + }
62 +});
63 +
64 +test('unknown sections and the legacy home variant fall back safely', () => {
65 + expect(parseOgParams(new Request('https://docs.composio.dev/api/og?section=nope&title=x')).section).toBe('docs');
66 + expect(parseOgParams(new Request('https://docs.composio.dev/api/og?variant=home')).section).toBe('home');
67 + expect(parseOgParams(new Request('https://docs.composio.dev/api/og')).title).toBe('Composio Docs');
68 + expect(parseOgParams(new Request(`https://docs.composio.dev/api/og?title=${'x'.repeat(500)}`)).title.length).toBe(120);
69 +});
70 +
71 +test('cards default to the dark surface and accept theme=light', async () => {
72 + expect(parseOgParams(new Request('https://docs.composio.dev/api/og?title=x')).theme).toBe('dark');
73 + const light = parseOgParams(new Request('https://docs.composio.dev/api/og?title=x&theme=light&logo=https%3A%2F%2Flogos.composio.dev%2Fapi%2Fgithub'));
74 + expect(light.theme).toBe('light');
75 + expect(light.logo).toBe('https://logos.composio.dev/api/github');
76 + await expectPng('https://docs.composio.dev/api/og?section=toolkits&title=GitHub&theme=light');
77 + await expectPng('https://docs.composio.dev/api/og?section=home&theme=light');
78 });