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:
BIN
assets/images/social-cards/actions.png
Normal file
BIN
assets/images/social-cards/actions.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 358 KiB |
BIN
assets/images/social-cards/copilot.png
Normal file
BIN
assets/images/social-cards/copilot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 300 KiB |
BIN
assets/images/social-cards/default.png
Normal file
BIN
assets/images/social-cards/default.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 519 KiB |
BIN
assets/images/social-cards/issues.png
Normal file
BIN
assets/images/social-cards/issues.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 285 KiB |
BIN
assets/images/social-cards/security.png
Normal file
BIN
assets/images/social-cards/security.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 344 KiB |
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user