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, { const { data, error } = await getClient().query(newsBySlugQuery, {
slug: params.slug, slug: params.slug,
}); });
const news = (data?.news ?? {}) as NewsFragment; const news = (data?.news ?? {}) as NewsFragment;
const featuredImage: any = news.featuredImage const featuredImage: any = news.featuredImage;
console.log(data)
console.log('error', error)
return ( return (
<main className="site-main" id="main"> <main className="site-main" id="main">
<section className="page-header"> <section className="page-header">
<h1>{news.title}</h1> <h1>{news.title}</h1>
{featuredImage && ( {featuredImage && (
<figure key={featuredImage.id}>
<Image <Image
src={featuredImage.url} src={featuredImage.url}
alt={featuredImage.alt} alt={featuredImage.alt ?? ""}
width={featuredImage.width} width={featuredImage.width}
height={featuredImage.height} height={featuredImage.height}
sizes="100vw" sizes="100vw"
/> />
<figcaption>Bildetekst her?</figcaption>
{featuredImage.attribution && (
<figcaption>{featuredImage.attribution}</figcaption>
)}
</figure>
)} )}
</section> </section>
<section className="page-content"> <section className="page-content">