Skip to content

Commit 3e25049

Browse files
committed
feat(og): use generated OG image on docs pages
1 parent 94d8f61 commit 3e25049

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

src/routes/$libraryId/$version.docs.$.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { seo } from '~/utils/seo'
2+
import { ogImageUrl } from '~/utils/og'
23
import { Doc } from '~/components/Doc'
34
import { loadDocsPage, resolveDocsRedirect } from '~/utils/docs'
45
import { findLibrary, getBranch, getLibrary } from '~/libraries'
@@ -72,6 +73,10 @@ export const Route = createFileRoute('/$libraryId/$version/docs/$')({
7273
meta: seo({
7374
title: `${loaderData?.title} | ${library.name} Docs`,
7475
description: loaderData?.description,
76+
image: ogImageUrl(library.id, {
77+
title: loaderData?.title,
78+
description: loaderData?.description,
79+
}),
7580
noindex: library.visible === false,
7681
}),
7782
}

src/routes/$libraryId/$version.docs.community-resources.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DocContainer } from '~/components/DocContainer'
44
import { DocTitle } from '~/components/DocTitle'
55
import { findLibrary, getBranch, getLibrary } from '~/libraries'
66
import { seo } from '~/utils/seo'
7+
import { ogImageUrl } from '~/utils/og'
78
import { loadDocs } from '~/utils/docs'
89

910
export const Route = createFileRoute(
@@ -37,6 +38,9 @@ export const Route = createFileRoute(
3738
meta: seo({
3839
title: `${library.name} Community Resources`,
3940
description: `A collection of community resources for ${library.name}.`,
41+
image: ogImageUrl(library.id, {
42+
title: `${library.name} · Community Resources`,
43+
}),
4044
noindex: library.visible === false,
4145
}),
4246
}

src/routes/$libraryId/$version.docs.framework.$framework.$.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
createFileRoute,
77
} from '@tanstack/react-router'
88
import { seo } from '~/utils/seo'
9+
import { ogImageUrl } from '~/utils/og'
910
import { Doc } from '~/components/Doc'
1011
import { loadDocsPage, resolveDocsRedirect } from '~/utils/docs'
1112
import { getBranch, getLibrary } from '~/libraries'
@@ -75,6 +76,10 @@ export const Route = createFileRoute(
7576
? `${ctx.loaderData.title} | ${tail}`
7677
: tail,
7778
description: ctx.loaderData?.description,
79+
image: ogImageUrl(library.id, {
80+
title: ctx.loaderData?.title,
81+
description: ctx.loaderData?.description,
82+
}),
7883
noindex: library.visible === false,
7984
}),
8085
}

src/routes/$libraryId/$version.docs.framework.$framework.examples.$.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getExampleStartingPath,
1414
} from '~/utils/sandbox'
1515
import { seo } from '~/utils/seo'
16+
import { ogImageUrl } from '~/utils/og'
1617
import { capitalize, slugToTitle } from '~/utils/utils'
1718
import * as v from 'valibot'
1819
import { CodeExplorer } from '~/components/CodeExplorer'
@@ -127,6 +128,10 @@ export const Route = createFileRoute(
127128
description: `An example showing how to implement ${slugToTitle(
128129
params._splat || '',
129130
)} in ${capitalize(params.framework)} using ${library.name}.`,
131+
image: ogImageUrl(library.id, {
132+
title: `${capitalize(params.framework)} ${library.name} ${slugToTitle(params._splat || '')} Example`,
133+
description: `An example showing how to implement ${slugToTitle(params._splat || '')} in ${capitalize(params.framework)} using ${library.name}.`,
134+
}),
130135
noindex: library.visible === false,
131136
}),
132137
}

src/routes/$libraryId/$version.index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { DocsLayout } from '~/components/DocsLayout'
88
import { findLibrary } from '~/libraries'
99
import { seo } from '~/utils/seo'
10+
import { ogImageUrl } from '~/utils/og'
1011

1112
import { Button } from '~/ui'
1213

@@ -25,6 +26,7 @@ export const Route = createFileRoute('/$libraryId/$version/')({
2526
meta: seo({
2627
title: library.name,
2728
description: library.description,
29+
image: ogImageUrl(library.id),
2830
noindex: library.visible === false,
2931
}),
3032
}

0 commit comments

Comments
 (0)