fix(nx-dev): Add png image file for ai blog socials (#27192)
This commit is contained in:
parent
8f83df012b
commit
4835c9fb6c
BIN
docs/blog/images/2024-07-29/explain-with-ai-header.png
Normal file
BIN
docs/blog/images/2024-07-29/explain-with-ai-header.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 244 KiB |
@ -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,
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user