mirror of
https://github.com/KazooTTT/kazoottt-blog-v2.git
synced 2025-06-23 18:51:30 +08:00
feat: show og image
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from "astro-icon/components";
|
import { Icon } from "astro-icon/components";
|
||||||
import ShareButtons from "./ShareButtons.astro";
|
import ShareButtons from "./ShareButtons.astro";
|
||||||
|
import { cn } from "@/utils/tailwind";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -9,7 +10,10 @@ export interface Props {
|
|||||||
const { className = "", dataPagefindBody = true } = Astro.props;
|
const { className = "", dataPagefindBody = true } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<article class="mx-auto max-w-3xl overflow-x-hidden px-4">
|
<article
|
||||||
|
class={cn("mx-auto max-w-3xl overflow-x-hidden px-4", className)}
|
||||||
|
data-pagefind-body={dataPagefindBody}
|
||||||
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
<div class="mt-8 border-t pt-4">
|
<div class="mt-8 border-t pt-4">
|
||||||
|
@ -9,27 +9,31 @@ import Label from "../componentsBefore/Label.astro";
|
|||||||
interface Props {
|
interface Props {
|
||||||
content: CollectionEntry<"post">;
|
content: CollectionEntry<"post">;
|
||||||
readingTime: string;
|
readingTime: string;
|
||||||
|
ogImage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
content: { data },
|
content: { data },
|
||||||
readingTime,
|
readingTime,
|
||||||
|
ogImage,
|
||||||
} = Astro.props;
|
} = Astro.props;
|
||||||
|
|
||||||
const dateTimeOptions: Intl.DateTimeFormatOptions = {
|
const dateTimeOptions: Intl.DateTimeFormatOptions = {
|
||||||
month: "long",
|
month: "long",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url).href;
|
||||||
---
|
---
|
||||||
|
|
||||||
{
|
{
|
||||||
data.banner && (
|
socialImageURL && (
|
||||||
<div class="mb-6 aspect-video">
|
<div class="mb-6 aspect-video">
|
||||||
<Image
|
<Image
|
||||||
alt={data.banner}
|
alt={socialImageURL}
|
||||||
class="object-cover"
|
class="object-cover"
|
||||||
fetchpriority="high"
|
fetchpriority="high"
|
||||||
loading="eager"
|
loading="eager"
|
||||||
src={data.banner}
|
src={socialImageURL}
|
||||||
inferSize={true}
|
inferSize={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,7 +38,9 @@ const readingTime: string = remarkPluginFrontmatter.readingTime;
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ArticleContainer className="grow break-words" dataPagefindBody={true}>
|
<ArticleContainer className="grow break-words" dataPagefindBody={true}>
|
||||||
<div id="blog-hero" class="mb-12"><Masthead content={post} readingTime={readingTime} /></div>
|
<div id="blog-hero" class="mb-12">
|
||||||
|
<Masthead content={post} readingTime={readingTime} ogImage={socialImage} />
|
||||||
|
</div>
|
||||||
<div class="flex flex-col gap-10 lg:flex-row lg:items-start">
|
<div class="flex flex-col gap-10 lg:flex-row lg:items-start">
|
||||||
{!!headings.length && <TOC headings={headings} />}
|
{!!headings.length && <TOC headings={headings} />}
|
||||||
<div
|
<div
|
||||||
|
Reference in New Issue
Block a user