Skip to content

Commit

Permalink
feat: use new og images in layout
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqmanuja authored and satnaing committed Sep 21, 2023
1 parent a83c871 commit ec3c691
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const {
} = Astro.props;
const socialImageURL = new URL(
ogImage ? ogImage : SITE.ogImage,
ogImage ?? SITE.ogImage ?? "og.png",
Astro.url.origin
).href;
---
Expand Down
5 changes: 4 additions & 1 deletion src/layouts/PostDetails.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const { title, author, description, ogImage, canonicalURL, pubDatetime, tags } =
const { Content } = await post.render();
const ogImageUrl = typeof ogImage === "string" ? ogImage : ogImage?.src;
const ogUrl = new URL(ogImageUrl ?? `${post.slug}.png`, Astro.url.origin).href;
const ogUrl = new URL(
ogImageUrl ?? `/posts/${slugifyStr(title)}.png`,
Astro.url.origin
).href;
---

<Layout
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type Site = {
author: string;
desc: string;
title: string;
ogImage: string;
ogImage?: string;
lightAndDarkMode: boolean;
postPerPage: number;
};
Expand Down

0 comments on commit ec3c691

Please sign in to comment.