fix(nx-dev): Add png image file for ai blog socials (#27192)

This commit is contained in:
Nicholas Cunningham 2024-07-29 13:46:18 -06:00 committed by GitHub
parent 8f83df012b
commit 4835c9fb6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

View File

@ -2,6 +2,7 @@ import type { Metadata, ResolvingMetadata } from 'next';
import { blogApi } from '../../../lib/blog.api';
import { BlogDetails } from '@nx/nx-dev/ui-blog';
import { DefaultLayout } from '@nx/nx-dev/ui-common';
import { parse } from 'path';
interface BlogPostDetailProps {
params: { slug: string };
}
@ -12,6 +13,10 @@ export async function generateMetadata(
): Promise<Metadata> {
const post = await blogApi.getBlogPostBySlug(slug);
const previousImages = (await parent).openGraph?.images ?? [];
const postCoverImage = post?.cover_image || 'nx-media';
const ogImage = `${parse(postCoverImage).name}.png`;
return {
title: `${post.title} | Nx Blog`,
description: 'Latest news from the Nx & Nx Cloud core team',
@ -21,13 +26,11 @@ export async function generateMetadata(
description: post.description,
images: [
{
url: post.cover_image
? `https://nx.dev${post.cover_image}`
: 'https://nx.dev/socials/nx-media.png',
url: ogImage,
width: 800,
height: 421,
alt: 'Nx: Smart, Fast and Extensible Build System',
type: 'image/jpeg',
type: 'image/png',
},
...previousImages,
],