fix: aspect ratio of previews

Signed-off-by: Filipe Medeiros <hello@filipesm.eu>
This commit is contained in:
Filipe Medeiros 2023-04-11 17:09:44 +01:00
parent d84fd7d6c1
commit c6a7c10055
Signed by: filipe
GPG key ID: 9533BD5467CC1E78
2 changed files with 4 additions and 1 deletions

View file

@ -10,7 +10,8 @@ export const forBlogPostPage = groq`
_type == 'image' => {
...,
"lqip": @.asset->metadata.lqip,
"alt": @.asset->altText
"alt": @.asset->altText,
"aspectRatio": @.asset->metadata.dimensions.aspectRatio
},
_type != 'image' => @
},

View file

@ -14,6 +14,7 @@ export interface BlogPostContentImage {
ref: string;
};
caption: PortableTextBlock[];
aspectRatio: number;
alt: string;
}
@ -27,6 +28,7 @@ const { node: value } = Astro.props;
alt={`${value.alt} Quando esta página carrega, esta imagem está desfocada para poupar dados e energia. Podes carregar na imagem para mostrar a imagem completa.`}
class="w-full border-2 border-primary-800"
data-url={urlFor(value).url()}
style={{ aspectRatio: value.aspectRatio }}
/>
<div
data-tooltip