add news article featured image to figure

This commit is contained in:
2024-05-21 00:25:06 +02:00
parent 06358ef1af
commit 4d9796fbe7

View File

@ -35,29 +35,31 @@ export default async function Page({ params }: { params: { slug: string } }) {
}
`);
const { data, error } = await getClient().query(newsBySlugQuery, {
slug: params.slug,
});
const news = (data?.news ?? {}) as NewsFragment;
const featuredImage: any = news.featuredImage
console.log(data)
console.log('error', error)
const featuredImage: any = news.featuredImage;
return (
<main className="site-main" id="main">
<section className="page-header">
<h1>{news.title}</h1>
{featuredImage && (
<figure key={featuredImage.id}>
<Image
src={featuredImage.url}
alt={featuredImage.alt}
alt={featuredImage.alt ?? ""}
width={featuredImage.width}
height={featuredImage.height}
sizes="100vw"
/>
<figcaption>Bildetekst her?</figcaption>
{featuredImage.attribution && (
<figcaption>{featuredImage.attribution}</figcaption>
)}
</figure>
)}
</section>
<section className="page-content">