fix: display placeholder image if no blog post cover image is present
This commit is contained in:
parent
3feba5be25
commit
62d5ccbb6d
3 changed files with 31 additions and 21 deletions
|
@ -64,7 +64,9 @@ export async function generateMetadata({
|
||||||
type: "website",
|
type: "website",
|
||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
url: urlFor(data.titleImage).url(),
|
url: data.titleImage
|
||||||
|
? urlFor(data.titleImage).url()
|
||||||
|
: "/blog-missing.png",
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
alt: `${data.title} - SVR.JS`
|
alt: `${data.title} - SVR.JS`
|
||||||
|
@ -76,7 +78,9 @@ export async function generateMetadata({
|
||||||
site: "@SVR_JS",
|
site: "@SVR_JS",
|
||||||
title: `${data.title} - SVR.JS`,
|
title: `${data.title} - SVR.JS`,
|
||||||
description: data.smallDescription,
|
description: data.smallDescription,
|
||||||
images: [urlFor(data.titleImage).url()],
|
images: [
|
||||||
|
data.titleImage ? urlFor(data.titleImage).url() : "/blog-missing.png"
|
||||||
|
],
|
||||||
creator: "@SVR_JS"
|
creator: "@SVR_JS"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -172,24 +176,26 @@ export default async function BlogSlugArticle({
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<header className="text-start mb-8 w-full">
|
<header className="text-start mb-8 w-full">
|
||||||
{data.titleImage && (
|
<div className="mb-2">
|
||||||
<div className="mb-2">
|
<h1 className="text-3xl md:text-5xl mb-8 py-4 font-bold text-black dark:bg-clip-text dark:text-transparent dark:bg-gradient-to-b dark:from-white dark:to-neutral-400">
|
||||||
<h1 className="text-3xl md:text-5xl mb-8 py-4 font-bold text-black dark:bg-clip-text dark:text-transparent dark:bg-gradient-to-b dark:from-white dark:to-neutral-400">
|
{data.title}
|
||||||
{data.title}
|
</h1>
|
||||||
</h1>
|
<Image
|
||||||
<Image
|
src={
|
||||||
src={urlFor(data.titleImage).url()}
|
data.titleImage
|
||||||
alt={data.title}
|
? urlFor(data.titleImage).url()
|
||||||
width={1200}
|
: "/blog-missing.png"
|
||||||
height={800}
|
}
|
||||||
priority
|
alt={data.title}
|
||||||
className="w-full h-auto object-cover rounded-md"
|
width={1200}
|
||||||
/>
|
height={800}
|
||||||
<p className="mt-4 text-lg md:text-xl text-muted-foreground">
|
priority
|
||||||
Uploaded at {formattedDate}
|
className="w-full h-auto object-cover rounded-md"
|
||||||
</p>
|
/>
|
||||||
</div>
|
<p className="mt-4 text-lg md:text-xl text-muted-foreground">
|
||||||
)}
|
Uploaded at {formattedDate}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<Separator className="mb-6" />
|
<Separator className="mb-6" />
|
||||||
<article className="prose max-w-full md:prose-lg dark:prose-invert">
|
<article className="prose max-w-full md:prose-lg dark:prose-invert">
|
||||||
|
|
|
@ -68,7 +68,11 @@ const BlogCards: React.FC<BlogCardsProps> = async ({ searchParams }) => {
|
||||||
<Link href={`/blog/${post.currentSlug}`} className="block">
|
<Link href={`/blog/${post.currentSlug}`} className="block">
|
||||||
<div className="relative overflow-hidden rounded-t-lg">
|
<div className="relative overflow-hidden rounded-t-lg">
|
||||||
<Image
|
<Image
|
||||||
src={urlFor(post.titleImage).url()}
|
src={
|
||||||
|
post.titleImage
|
||||||
|
? urlFor(post.titleImage).url()
|
||||||
|
: "/blog-missing.png"
|
||||||
|
}
|
||||||
alt={post.title}
|
alt={post.title}
|
||||||
width={500}
|
width={500}
|
||||||
height={300}
|
height={300}
|
||||||
|
|
BIN
public/blog-missing.png
Normal file
BIN
public/blog-missing.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
Loading…
Reference in a new issue