@devries-cameron20 / composio Mirror · read-only / commits / 37a647d1c
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, 13:30 UTC

fix(docs): serve social preview images from the docs host

Brendan O'Leary committed Sep 10, 2026 at 11:21 UTC 37a647d1c44f5f17c6d703af0c9514ca02d357df
4 files changed +48 -3
docs/app/api/og/route.tsx new
+28
@@ -0,0 +1,28 @@
1 +import { ImageResponse } from 'next/og';
2 +
3 +export function GET(request: Request) {
4 + const input = new URL(request.url).searchParams.get('title')?.trim();
5 + const title = Array.from(input || 'Composio Docs').slice(0, 120).join('');
6 +
7 + return new ImageResponse(
8 + <div style={{
9 + display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
10 + width: '100%', height: '100%', padding: 72, background: '#131211', color: '#faf9f6',
11 + fontFamily: 'sans-serif',
12 + }}>
13 + <div style={{ display: 'flex', alignItems: 'center', gap: 18, fontSize: 32 }}>
14 + <div style={{ width: 28, height: 28, background: '#f76b15', borderRadius: 6 }} />
15 + Composio Docs
16 + </div>
17 + <div style={{ display: 'flex', fontSize: title.length > 60 ? 48 : 68, lineHeight: 1.12,
18 + letterSpacing: -2, maxWidth: 1056, overflowWrap: 'break-word' }}>
19 + {title}
20 + </div>
21 + <div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 24, color: '#bbb7b0' }}>
22 + <span>Build and operate agents</span>
23 + <span>docs.composio.dev</span>
24 + </div>
25 + </div>,
26 + { width: 1200, height: 630, headers: { 'Cache-Control': 'public, max-age=86400' } },
27 + );
28 +}
docs/app/layout.tsx
+2 -2
@@ -48,13 +48,13 @@ export const metadata: Metadata = {
48 description: SITE_DESCRIPTION,
49 siteName: 'Composio Docs',
50 type: 'website',
51 - images: ['https://og.composio.dev/api/og?title=Composio%20Docs'],
51 + images: ['https://docs.composio.dev/api/og?title=Composio%20Docs'],
52 },
53 twitter: {
54 card: 'summary_large_image',
55 title: 'Composio Docs',
56 description: SITE_DESCRIPTION,
57 - images: ['https://og.composio.dev/api/og?title=Composio%20Docs'],
57 + images: ['https://docs.composio.dev/api/og?title=Composio%20Docs'],
58 },
59 };
60
docs/lib/source.ts
+1 -1
@@ -163,7 +163,7 @@ export function getOgImageUrl(
163 _description?: string
164 ): string {
165 const encodedTitle = encodeURIComponent(title ?? 'Composio Docs');
166 - return `https://og.composio.dev/api/og?title=${encodedTitle}`;
166 + return `https://docs.composio.dev/api/og?title=${encodedTitle}`;
167 }
168
169 /**
docs/tests/static/og-image.test.ts new
+17
@@ -0,0 +1,17 @@
1 +import { expect, test } from 'bun:test';
2 +import { GET } from '../../app/api/og/route';
3 +import { getOgImageUrl } from '../../lib/source';
4 +
5 +test('docs host renders a PNG for the advertised title URL', async () => {
6 + for (const title of ['Welcome', 'Authentication & OAuth / setup', 'Very long title '.repeat(20), '']) {
7 + const url = getOgImageUrl('docs', [], title);
8 + 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);
16 + }
17 +});