Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): render docs OG cards on Twitter/X (#2589)

sarahd279fd7b7250
diff --git a/docs/src/app/d/[encoded]/opengraph-image.tsx b/docs/src/app/d/[encoded]/opengraph-image.tsx
index cd9253688..6c507057e 100644
--- a/docs/src/app/d/[encoded]/opengraph-image.tsx
+++ b/docs/src/app/d/[encoded]/opengraph-image.tsx
@@ -4,8 +4,8 @@ import {
dmSansFontsArg,
type FontPair,
loadDmSans,
- OG_CACHE_HEADERS,
OG_CONTENT_TYPE,
+ OG_RESPONSE_HEADERS,
OG_SIZE,
ShareCard,
} from '@/lib/og-card';
@@ -56,6 +56,6 @@ export function renderShareOgImage(view: SplashView, fonts: FontPair | null): Im
return new ImageResponse(body, {
...OG_SIZE,
fonts: dmSansFontsArg(fonts),
- headers: OG_CACHE_HEADERS,
+ headers: OG_RESPONSE_HEADERS,
});
}
diff --git a/docs/src/app/og/docs/[...slug]/route.tsx b/docs/src/app/og/docs/[...slug]/route.tsx
index 1f2c08898..75af21bad 100644
--- a/docs/src/app/og/docs/[...slug]/route.tsx
+++ b/docs/src/app/og/docs/[...slug]/route.tsx
@@ -4,8 +4,8 @@ import {
DocPageCard,
dmSansFontsArg,
loadDmSans,
- OG_CACHE_HEADERS,
OG_CONTENT_TYPE,
+ OG_RESPONSE_HEADERS,
OG_SIZE,
} from '@/lib/og-card';
import { source } from '@/lib/source';
@@ -36,7 +36,7 @@ export async function GET(_request: Request, props: RouteProps) {
{
...OG_SIZE,
fonts: dmSansFontsArg(fonts),
- headers: { ...OG_CACHE_HEADERS, 'Content-Type': OG_CONTENT_TYPE },
+ headers: { ...OG_RESPONSE_HEADERS, 'Content-Type': OG_CONTENT_TYPE },
},
);
}
diff --git a/docs/src/app/opengraph-image.tsx b/docs/src/app/opengraph-image.tsx
index 75e6e19ba..19e3215dc 100644
--- a/docs/src/app/opengraph-image.tsx
+++ b/docs/src/app/opengraph-image.tsx
@@ -3,8 +3,8 @@ import {
BrandCard,
dmSansFontsArg,
loadDmSans,
- OG_CACHE_HEADERS,
OG_CONTENT_TYPE,
+ OG_RESPONSE_HEADERS,
OG_SIZE,
} from '@/lib/og-card';
import { SITE_HEADLINE, SITE_NAME } from '@/lib/site';
@@ -19,6 +19,6 @@ export default async function OgImage() {
return new ImageResponse(<BrandCard />, {
...OG_SIZE,
fonts: dmSansFontsArg(fonts),
- headers: OG_CACHE_HEADERS,
+ headers: OG_RESPONSE_HEADERS,
});
}
diff --git a/docs/src/app/robots.ts b/docs/src/app/robots.ts
index 931fe6b82..f115fd3d5 100644
--- a/docs/src/app/robots.ts
+++ b/docs/src/app/robots.ts
@@ -7,7 +7,7 @@ export default function robots(): MetadataRoute.Robots {
{
userAgent: '*',
allow: '/',
- disallow: ['/api/', '/d/', '/og/'],
+ disallow: ['/api/', '/d/'],
},
],
sitemap: `${SITE_URL}/sitemap.xml`,
diff --git a/docs/src/lib/og-card.tsx b/docs/src/lib/og-card.tsx
index ea0e0e064..de13833d1 100644
--- a/docs/src/lib/og-card.tsx
+++ b/docs/src/lib/og-card.tsx
@@ -18,8 +18,19 @@ import { SITE_HEADLINE } from './site';
export const OG_SIZE = { width: 1200, height: 630 } as const;
export const OG_CONTENT_TYPE = 'image/png';
-export const OG_CACHE_HEADERS = {
+/**
+ * Response headers for every OG-image route (home, per-docs-page, share).
+ *
+ * `X-Robots-Tag: noindex` keeps these card images out of search indexes
+ * WITHOUT a robots.txt `Disallow`. A `Disallow` blocks Twitterbot (which
+ * honors robots.txt) from fetching the card, so the image silently fails to
+ * render in X/Twitter link previews while still loading on scrapers that
+ * ignore robots.txt (Facebook, Slack). `noindex` at the response layer lets
+ * every crawler fetch the image but tells indexers not to list it.
+ */
+export const OG_RESPONSE_HEADERS = {
'Cache-Control': 'public, max-age=31536000, immutable',
+ 'X-Robots-Tag': 'noindex',
} as const;
const BG = '#fbf9f4';