Skip to content

Commit

Permalink
Merge pull request #26 from azvyae/fix/opengraph-image
Browse files Browse the repository at this point in the history
Force opengraph image on stories to use cover instead
  • Loading branch information
Azvya Erstevan authored Aug 29, 2024
2 parents 534266d + 9448fa1 commit a72331f
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/app/stories/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { StoriesIndexEntry } from '@/types/common';
import { readFileSync } from 'fs';
import matter from 'gray-matter';
import jsonata from 'jsonata';
import type { Metadata, ResolvingMetadata } from 'next';
import type { Metadata } from 'next';
import Link from 'next/link';
import { notFound } from 'next/navigation';
import path from 'path';
Expand Down Expand Up @@ -66,14 +66,9 @@ async function listRandomStories() {
}
}

export async function generateMetadata(
{ params }: Props,
parent: ResolvingMetadata,
): Promise<Metadata> {
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const story = await getStoryBySlug(params.slug);

const previousImages = (await parent).openGraph?.images || [];

return {
title: story.title,
description: story.subtitle,
Expand All @@ -82,12 +77,12 @@ export async function generateMetadata(
twitter: {
title: story.title,
description: story.subtitle,
images: [story.cover, ...previousImages],
images: story.cover,
},
openGraph: {
title: story.title,
description: story.subtitle,
images: [story.cover, ...previousImages],
images: story.cover,
},
};
}
Expand Down

0 comments on commit a72331f

Please sign in to comment.