Skip to content

Commit 28515a8

Browse files
woops
1 parent 4301d8b commit 28515a8

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/layouts/BlogPost.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ type Props = CollectionEntry<"blog">["data"] & { slug: string };
88
const { title, description, pubDate, updatedDate, heroImage, slug } =
99
Astro.props;
1010
11-
export const buildOGURL = (title: string | undefined) => {
11+
export const buildOGURL = (slug: string | undefined) => {
1212
const url = new URL("https://image.memp.dev/api");
13-
title && url.searchParams.set("title", `/${slug}`);
13+
slug && url.searchParams.set("title", `/${slug}`);
1414
return url.toString();
1515
};
1616
---
@@ -19,7 +19,7 @@ export const buildOGURL = (title: string | undefined) => {
1919
<article class="flex w-full flex-col items-center gap-6">
2020
{title && <h1 class="text-center text-4xl font-bold">{title}</h1>}
2121
<img
22-
src={heroImage || buildOGURL(title)}
22+
src={heroImage || buildOGURL(slug)}
2323
alt=""
2424
class="mb-6 w-full rounded-xl shadow-lg md:max-w-4xl"
2525
/>

src/pages/blog/[...slug].astro

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ const post = Astro.props;
1515
const { Content } = await post.render();
1616
---
1717

18-
<BlogPost
19-
{...post.data}
20-
slug={post.slug}
21-
heroImage={buildOGURL(post.data.title)}
22-
>
18+
<BlogPost {...post.data} slug={post.slug} heroImage={buildOGURL(post.slug)}>
2319
<Content />
2420
<script
2521
src="https://utteranc.es/client.js"

0 commit comments

Comments
 (0)