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