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"),
|
slug: q.slug("slug"),
|
||||||
publishedAt: q.date(),
|
publishedAt: q.date(),
|
||||||
content: q.string(),
|
content: q.string(),
|
||||||
mainImage: q("mainImage").grabOne$("asset->url", q.string()),
|
mainImage: q("mainImage").grabOne$("asset->url", q.string().optional()),
|
||||||
})
|
})
|
||||||
.slice(0, 1);
|
.slice(0, 1);
|
||||||
|
|
||||||
const post = schema.parse(await client.fetch(query))[0];
|
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 (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center min-h-screen py-2">
|
<div className="flex flex-col items-center justify-center min-h-screen py-2">
|
||||||
|
@ -44,6 +44,7 @@ export default async function Page({
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{post.mainImage && (
|
||||||
<Image
|
<Image
|
||||||
className="object-cover w-full h-full"
|
className="object-cover w-full h-full"
|
||||||
src={post.mainImage}
|
src={post.mainImage}
|
||||||
|
@ -51,6 +52,7 @@ export default async function Page({
|
||||||
width={parseInt(r?.groups?.width ?? "400")}
|
width={parseInt(r?.groups?.width ?? "400")}
|
||||||
height={parseInt(r?.groups?.height ?? "400")}
|
height={parseInt(r?.groups?.height ?? "400")}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,12 @@ export default async function Page() {
|
||||||
subtitle: q.string(),
|
subtitle: q.string(),
|
||||||
slug: q.slug("slug"),
|
slug: q.slug("slug"),
|
||||||
publishedAt: q.date(),
|
publishedAt: q.date(),
|
||||||
mainImage: q("mainImage").grabOne$("asset->url", q.string()),
|
mainImage: q("mainImage").grabOne$("asset->url", q.string().optional()),
|
||||||
categories: q("categories")
|
categories: q("categories")
|
||||||
.filter()
|
.filter()
|
||||||
.deref()
|
.deref()
|
||||||
.grabOne$("title", q.string()),
|
.grabOne$("title", q.string())
|
||||||
|
.nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const posts = schema.parse(await client.fetch(query));
|
const posts = schema.parse(await client.fetch(query));
|
||||||
|
@ -38,7 +39,7 @@ export default async function Page() {
|
||||||
<div className="dark:bg-zinc-900">
|
<div className="dark:bg-zinc-900">
|
||||||
<section className="grid grid-cols-2 gap-4 py-8 mx-auto max-w-7xl">
|
<section className="grid grid-cols-2 gap-4 py-8 mx-auto max-w-7xl">
|
||||||
{posts.map((post) => {
|
{posts.map((post) => {
|
||||||
const r = post.mainImage.match(/(?<width>\d+)x(?<height>\d+)/);
|
const r = post.mainImage?.match(/(?<width>\d+)x(?<height>\d+)/);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
|
@ -46,15 +47,18 @@ 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"
|
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}`}
|
href={`/blog/${post.slug}`}
|
||||||
>
|
>
|
||||||
|
{post.mainImage && (
|
||||||
<Image
|
<Image
|
||||||
src={post.mainImage}
|
src={post.mainImage}
|
||||||
alt={post.title}
|
alt={post.title}
|
||||||
width={parseInt(r?.groups?.width ?? "400")}
|
width={parseInt(r?.groups?.width ?? "400")}
|
||||||
height={parseInt(r?.groups?.height ?? "400")}
|
height={parseInt(r?.groups?.height ?? "400")}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<h3 className="text-xl font-semibold">{post.title}</h3>
|
<h3 className="text-xl font-semibold">{post.title}</h3>
|
||||||
<p className="text-lg">{post.subtitle}</p>
|
<p className="text-lg">{post.subtitle}</p>
|
||||||
|
|
||||||
|
{post.categories && post.categories.length > 0 && (
|
||||||
<p className="text-md text-zinc-400">
|
<p className="text-md text-zinc-400">
|
||||||
Categories:
|
Categories:
|
||||||
{post.categories.map((category) => (
|
{post.categories.map((category) => (
|
||||||
|
@ -66,6 +70,7 @@ export default async function Page() {
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</p>
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<time
|
<time
|
||||||
|
|
|
@ -17,7 +17,8 @@ export default async function Page() {
|
||||||
categories: q("categories")
|
categories: q("categories")
|
||||||
.filter()
|
.filter()
|
||||||
.deref()
|
.deref()
|
||||||
.grabOne$("title", q.string()),
|
.grabOne$("title", q.string())
|
||||||
|
.nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const projects = projectSchema.parse(await client.fetch(projectQuery));
|
const projects = projectSchema.parse(await client.fetch(projectQuery));
|
||||||
|
@ -59,7 +60,8 @@ export default async function Page() {
|
||||||
<p className="text-lg">{project.subtitle}</p>
|
<p className="text-lg">{project.subtitle}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="flex-grow">
|
<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">
|
<div className="flex flex-wrap flex-grow gap-1 text-md dark:text-zinc-400 text-slate-600">
|
||||||
<span className="w-full">Categories:</span>
|
<span className="w-full">Categories:</span>
|
||||||
{project.categories.map((category) => (
|
{project.categories.map((category) => (
|
||||||
|
@ -71,7 +73,8 @@ export default async function Page() {
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</p>
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center mt-auto space-x-2">
|
<div className="flex items-center mt-auto space-x-2">
|
||||||
<time
|
<time
|
||||||
|
|
Loading…
Reference in New Issue
Block a user