Skip to content

Commit

Permalink
fix: captions on images (#87)
Browse files Browse the repository at this point in the history
* fix: captions on images

Signed-off-by: james-a-morris <[email protected]>

* nit: lint

Signed-off-by: james-a-morris <[email protected]>

---------

Signed-off-by: james-a-morris <[email protected]>
  • Loading branch information
james-a-morris authored Nov 13, 2024
1 parent 309eb0b commit 2064db8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const nodeRenderers: RenderNode = {
const mimeGroup = file?.contentType.split("/")[0]; // image / video etc
switch (mimeGroup) {
case "image":
return <ContentfulImage image={data} />;
return <ContentfulImage image={data} displayDescription />;
// TODO: test this, make custom component if necessary
case "video":
return (
Expand Down
6 changes: 4 additions & 2 deletions src/app/(routes)/blog/[slug]/_components/contentful-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ContentfulImage({
};

return (
<div className="relative flex h-full w-full flex-col items-center gap-4">
<div className="relative flex h-full w-full flex-col items-center gap-2 pb-2">
<Image
src={urlWithProtocol}
alt={description ?? "description"}
Expand All @@ -43,7 +43,9 @@ export default function ContentfulImage({
aria-description={description}
{...props}
/>
{description && displayDescription && <p>{description}</p>}
{description && displayDescription && (
<p className="font-extralight">{description}</p>
)}
</div>
);
}

0 comments on commit 2064db8

Please sign in to comment.