Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(docs): improve homepage social preview
Brendan O'Leary committed
Sep 10, 2026 at 12:05 UTC
b972a93b226df213eab1a2bf79ff9564a22c8ada
7 files changed
+100
-12
docs/app/(home)/docs/[[...slug]]/page.tsx
+16
-3
@@ -72,10 +72,23 @@ export async function generateMetadata(props: PageProps<'/docs/[[...slug]]'>): P
72
const ogImage = getOgImageUrl('docs', page.slugs, page.data.title, page.data.description);
73
74
return {
75
- title: page.data.title,
75
+ title: page.slugs.length === 0
76
+ ? { absolute: `${page.data.title} | Composio Documentation` }
77
+ : page.data.title,
78
description: page.data.description,
79
alternates: { canonical: page.url },
78
- openGraph: { images: [ogImage] },
79
- twitter: { card: 'summary_large_image', images: [ogImage] },
80
+ openGraph: {
81
+ title: page.data.title,
82
+ description: page.data.description,
83
+ siteName: 'Composio Docs',
84
+ type: 'website',
85
+ images: [ogImage],
86
+ },
87
+ twitter: {
88
+ card: 'summary_large_image',
89
+ title: page.data.title,
90
+ description: page.data.description,
91
+ images: [ogImage],
92
+ },
93
};
94
}
docs/app/api/og/route.tsx
+47
-2
@@ -1,10 +1,54 @@
1
import { ImageResponse } from 'next/og';
2
3
export function GET(request: Request) {
4
- const input = new URL(request.url).searchParams.get('title')?.trim();
4
+ 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('');
7
8
return new ImageResponse(
9
+ params.get('variant') === 'home' ? (
10
+ <div style={{
11
+ display: 'flex', width: '100%', height: '100%',
12
+ background: '#131211', color: '#faf9f6', fontFamily: 'sans-serif',
13
+ }}>
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>
32
+ </div>
33
+ <div style={{
34
+ display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
35
+ width: 390, padding: '64px 40px', background: '#f76b15', color: '#131211',
36
+ }}>
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>
49
+ </div>
50
+ </div>
51
+ ) : (
52
<div style={{
53
display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
54
width: '100%', height: '100%', padding: 72, background: '#131211', color: '#faf9f6',
@@ -22,7 +66,8 @@ export function GET(request: Request) {
66
<span>Build and operate agents</span>
67
<span>docs.composio.dev</span>
68
</div>
25
- </div>,
69
+ </div>
70
+ ),
71
{ width: 1200, height: 630, headers: { 'Cache-Control': 'public, max-age=86400' } },
72
);
73
}
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://docs.composio.dev/api/og?title=Composio%20Docs'],
51
+ images: ['https://docs.composio.dev/api/og?variant=home'],
52
},
53
twitter: {
54
card: 'summary_large_image',
55
title: 'Composio Docs',
56
description: SITE_DESCRIPTION,
57
- images: ['https://docs.composio.dev/api/og?title=Composio%20Docs'],
57
+ images: ['https://docs.composio.dev/api/og?variant=home'],
58
},
59
};
60
docs/content/docs/index.mdx
+2
-2
@@ -1,6 +1,6 @@
1
---
2
-title: Welcome
3
-description: Choose whether to build Composio into an application or use it from an existing agent, then start with the SDK, a native plugin, the CLI, or MCP.
2
+title: Build and operate AI agents
3
+description: Give your agents tools, managed authentication, and secure execution. Get started with the SDK, CLI, or MCP.
4
keywords: [getting started, introduction]
5
---
6
docs/lib/source.ts
+5
-2
@@ -157,11 +157,14 @@ export type ChangelogEntry = DocCollectionEntry<
157
export const changelogEntries = changelog as ChangelogEntry[];
158
159
export function getOgImageUrl(
160
- _section: string,
161
- _slugs: string[],
160
+ section: string,
161
+ slugs: string[],
162
title?: string,
163
_description?: string
164
): string {
165
+ if (section === 'docs' && slugs.length === 0) {
166
+ return 'https://docs.composio.dev/api/og?variant=home';
167
+ }
168
const encodedTitle = encodeURIComponent(title ?? 'Composio Docs');
169
return `https://docs.composio.dev/api/og?title=${encodedTitle}`;
170
}
docs/tests/integration/rendering.test.ts
+15
@@ -58,6 +58,21 @@ describe("Page rendering - critical pages", () => {
58
});
59
60
describe("Page rendering - content markers", () => {
61
+ test("docs homepage social metadata survives the root redirect", async () => {
62
+ const res = await fetchPage("/", { timeout: 30_000, headers: { "User-Agent": "facebookexternalhit/1.1" } });
63
+ const html = await res.text();
64
+ expect(res.status).toBe(200);
65
+ expect(new URL(res.url).pathname).toBe('/docs');
66
+ expect(html).toContain('<title>Build and operate AI agents | Composio Documentation</title>');
67
+ expect(html).toContain('<meta property="og:site_name" content="Composio Docs"');
68
+ expect(html).toContain('<meta property="og:title" content="Build and operate AI agents"');
69
+ expect(html).toContain('<meta property="og:image" content="https://docs.composio.dev/api/og?variant=home"');
70
+ expect(html).toContain('<meta name="twitter:image" content="https://docs.composio.dev/api/og?variant=home"');
71
+ const description = html.match(/<meta property="og:description" content="([^"]+)"/)?.[1];
72
+ expect(description).toBe('Give your agents tools, managed authentication, and secure execution. Get started with the SDK, CLI, or MCP.');
73
+ expect(description!.length).toBeLessThanOrEqual(125);
74
+ });
75
+
76
test("docs home contains navigation elements", async () => {
77
const res = await fetchPage("/docs");
78
const html = await res.text();
docs/tests/static/og-image.test.ts
+13
-1
@@ -4,7 +4,7 @@ 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);
7
+ const url = getOgImageUrl('docs', ['authentication'], 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);
@@ -15,3 +15,15 @@ test('docs host renders a PNG for the advertised title URL', async () => {
15
expect(bytes.readUInt32BE(20)).toBe(630);
16
}
17
});
18
+
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);
29
+});