1
0
mirror of synced 2025-12-19 18:10:59 -05:00

enable category-specific social preview images (#54936)

Co-authored-by: Rachael Sewell <rachmari@github.com>
Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
This commit is contained in:
Roniece Ricardo
2025-04-07 11:32:41 -04:00
committed by GitHub
parent 51feec854d
commit a34b88ba1f
6 changed files with 15 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

View File

@@ -59,6 +59,20 @@ export const DefaultLayout = (props: Props) => {
const metaDescription = page.introPlainText ? page.introPlainText : t('default_description') const metaDescription = page.introPlainText ? page.introPlainText : t('default_description')
const SOCIAL_CATEGORIES = new Set(['security', 'actions', 'issues', 'copilot'])
const SOCIAL_CARD_IMG_BASE_URL = '/assets/cb-345/images/social-cards'
function getCategoryImageUrl(category: string): string {
return `${SOCIAL_CARD_IMG_BASE_URL}/${category}.png`
}
function getSocialCardImage(): string {
if (currentProduct && SOCIAL_CATEGORIES.has(currentProduct.id)) {
return getCategoryImageUrl(currentProduct.id)
}
return getCategoryImageUrl('default')
}
return ( return (
<DomainNameEditProvider> <DomainNameEditProvider>
<Head> <Head>
@@ -111,10 +125,7 @@ export const DefaultLayout = (props: Props) => {
<meta property="og:title" content={page.fullTitle} /> <meta property="og:title" content={page.fullTitle} />
<meta property="og:type" content="article" /> <meta property="og:type" content="article" />
<meta property="og:url" content={fullUrl} /> <meta property="og:url" content={fullUrl} />
<meta <meta property="og:image" content={getSocialCardImage()} />
property="og:image"
content="https://github.githubassets.com/images/modules/open_graph/github-logo.png"
/>
</> </>
)} )}
</Head> </Head>