fix: build errors
This commit is contained in:
parent
f4318dcda8
commit
ac779e3fd4
|
@ -20,13 +20,13 @@ export default async function Page({
|
|||
slug: q.slug("slug"),
|
||||
publishedAt: q.date(),
|
||||
content: q.string(),
|
||||
mainImage: q("mainImage").grabOne$("asset->url", q.string()),
|
||||
mainImage: q("mainImage").grabOne$("asset->url", q.string().optional()),
|
||||
})
|
||||
.slice(0, 1);
|
||||
|
||||
const post = schema.parse(await client.fetch(query))[0];
|
||||
|
||||
const r = post.mainImage.match(/(?<width>\d+)x(?<height>\d+)/);
|
||||
const r = post.mainImage?.match(/(?<width>\d+)x(?<height>\d+)/);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center min-h-screen py-2">
|
||||
|
@ -44,13 +44,15 @@ export default async function Page({
|
|||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<Image
|
||||
className="object-cover w-full h-full"
|
||||
src={post.mainImage}
|
||||
alt={post.title}
|
||||
width={parseInt(r?.groups?.width ?? "400")}
|
||||
height={parseInt(r?.groups?.height ?? "400")}
|
||||
/>
|
||||
{post.mainImage && (
|
||||
<Image
|
||||
className="object-cover w-full h-full"
|
||||
src={post.mainImage}
|
||||
alt={post.title}
|
||||
width={parseInt(r?.groups?.width ?? "400")}
|
||||
height={parseInt(r?.groups?.height ?? "400")}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -13,11 +13,12 @@ export default async function Page() {
|
|||
subtitle: q.string(),
|
||||
slug: q.slug("slug"),
|
||||
publishedAt: q.date(),
|
||||
mainImage: q("mainImage").grabOne$("asset->url", q.string()),
|
||||
mainImage: q("mainImage").grabOne$("asset->url", q.string().optional()),
|
||||
categories: q("categories")
|
||||
.filter()
|
||||
.deref()
|
||||
.grabOne$("title", q.string()),
|
||||
.grabOne$("title", q.string())
|
||||
.nullable(),
|
||||
});
|
||||
|
||||
const posts = schema.parse(await client.fetch(query));
|
||||
|
@ -38,7 +39,7 @@ export default async function Page() {
|
|||
<div className="dark:bg-zinc-900">
|
||||
<section className="grid grid-cols-2 gap-4 py-8 mx-auto max-w-7xl">
|
||||
{posts.map((post) => {
|
||||
const r = post.mainImage.match(/(?<width>\d+)x(?<height>\d+)/);
|
||||
const r = post.mainImage?.match(/(?<width>\d+)x(?<height>\d+)/);
|
||||
|
||||
return (
|
||||
<Link
|
||||
|
@ -46,26 +47,30 @@ export default async function Page() {
|
|||
className="flex flex-col items-center justify-center pb-4 space-y-4 overflow-hidden transition-all duration-150 rounded-md dark:bg-zinc-800 hover:scale-105"
|
||||
href={`/blog/${post.slug}`}
|
||||
>
|
||||
<Image
|
||||
src={post.mainImage}
|
||||
alt={post.title}
|
||||
width={parseInt(r?.groups?.width ?? "400")}
|
||||
height={parseInt(r?.groups?.height ?? "400")}
|
||||
/>
|
||||
{post.mainImage && (
|
||||
<Image
|
||||
src={post.mainImage}
|
||||
alt={post.title}
|
||||
width={parseInt(r?.groups?.width ?? "400")}
|
||||
height={parseInt(r?.groups?.height ?? "400")}
|
||||
/>
|
||||
)}
|
||||
<h3 className="text-xl font-semibold">{post.title}</h3>
|
||||
<p className="text-lg">{post.subtitle}</p>
|
||||
|
||||
<p className="text-md text-zinc-400">
|
||||
Categories:
|
||||
{post.categories.map((category) => (
|
||||
<span
|
||||
key={category}
|
||||
className="px-2 py-1 ml-2 text-sm font-semibold text-white bg-indigo-500 rounded-md"
|
||||
>
|
||||
{category}
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
{post.categories && post.categories.length > 0 && (
|
||||
<p className="text-md text-zinc-400">
|
||||
Categories:
|
||||
{post.categories.map((category) => (
|
||||
<span
|
||||
key={category}
|
||||
className="px-2 py-1 ml-2 text-sm font-semibold text-white bg-indigo-500 rounded-md"
|
||||
>
|
||||
{category}
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="flex items-center space-x-2">
|
||||
<time
|
||||
|
|
|
@ -17,7 +17,8 @@ export default async function Page() {
|
|||
categories: q("categories")
|
||||
.filter()
|
||||
.deref()
|
||||
.grabOne$("title", q.string()),
|
||||
.grabOne$("title", q.string())
|
||||
.nullable(),
|
||||
});
|
||||
|
||||
const projects = projectSchema.parse(await client.fetch(projectQuery));
|
||||
|
@ -59,19 +60,21 @@ export default async function Page() {
|
|||
<p className="text-lg">{project.subtitle}</p>
|
||||
</div>
|
||||
|
||||
<p className="flex-grow">
|
||||
<div className="flex flex-wrap flex-grow gap-1 text-md dark:text-zinc-400 text-slate-600">
|
||||
<span className="w-full">Categories:</span>
|
||||
{project.categories.map((category) => (
|
||||
<span
|
||||
key={category}
|
||||
className="px-2 py-1 text-sm font-semibold text-white bg-indigo-500 rounded-md"
|
||||
>
|
||||
{category}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</p>
|
||||
<div className="flex-grow">
|
||||
{project.categories && project.categories.length > 0 && (
|
||||
<div className="flex flex-wrap flex-grow gap-1 text-md dark:text-zinc-400 text-slate-600">
|
||||
<span className="w-full">Categories:</span>
|
||||
{project.categories.map((category) => (
|
||||
<span
|
||||
key={category}
|
||||
className="px-2 py-1 text-sm font-semibold text-white bg-indigo-500 rounded-md"
|
||||
>
|
||||
{category}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center mt-auto space-x-2">
|
||||
<time
|
||||
|
|
Loading…
Reference in New Issue
Block a user