feat: show og image

This commit is contained in:
KazooTTT
2025-02-06 14:54:20 +08:00
parent 09f1dfde9d
commit f7aece07e8
3 changed files with 15 additions and 5 deletions

View File

@ -9,27 +9,31 @@ import Label from "../componentsBefore/Label.astro";
interface Props {
content: CollectionEntry<"post">;
readingTime: string;
ogImage: string;
}
const {
content: { data },
readingTime,
ogImage,
} = Astro.props;
const dateTimeOptions: Intl.DateTimeFormatOptions = {
month: "long",
};
const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url).href;
---
{
data.banner && (
socialImageURL && (
<div class="mb-6 aspect-video">
<Image
alt={data.banner}
alt={socialImageURL}
class="object-cover"
fetchpriority="high"
loading="eager"
src={data.banner}
src={socialImageURL}
inferSize={true}
/>
</div>