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 && (
<Image <figure key={featuredImage.id}>
src={featuredImage.url} <Image
alt={featuredImage.alt} src={featuredImage.url}
width={featuredImage.width} alt={featuredImage.alt ?? ""}
height={featuredImage.height} width={featuredImage.width}
sizes="100vw" height={featuredImage.height}
/> sizes="100vw"
/>
<figcaption>Bildetekst her?</figcaption>
{featuredImage.attribution && (
<figcaption>{featuredImage.attribution}</figcaption>
)}
</figure>
)} )}
</section> </section>
<section className="page-content"> <section className="page-content">