mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
refactor: convert Picture component to use AstroImageTools
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
---
|
||||
import cx from 'classnames';
|
||||
|
||||
import { Picture } from '@astrojs/image/components';
|
||||
import type { PictureComponentLocalImageProps } from '@astrojs/image/components';
|
||||
import { Picture } from 'astro-imagetools/components';
|
||||
import type { PictureConfigOptions } from 'astro-imagetools';
|
||||
|
||||
interface Props extends PictureComponentLocalImageProps {
|
||||
interface Props extends PictureConfigOptions {
|
||||
class?: string;
|
||||
noMargin?: boolean;
|
||||
slot?: string;
|
||||
}
|
||||
|
||||
const { class: className, noMargin, ...props } = Astro.props;
|
||||
|
||||
@@ -18,9 +18,9 @@ const { project } = Astro.props;
|
||||
) : (
|
||||
<Picture
|
||||
alt={project.data.title}
|
||||
aspectRatio={project.data.image.aspectRatio as number | `${number}:${number}`}
|
||||
formats={['webp', 'avif']}
|
||||
widths={[300, 500, 700, 1000, 1200, 1500]}
|
||||
aspect={project.data.image.aspectRatio}
|
||||
breakpoints={[300, 500, 700, 1000, 1200, 1500]}
|
||||
format={['webp', 'avif']}
|
||||
src={project.data.image.src}
|
||||
/>
|
||||
))
|
||||
|
||||
@@ -17,7 +17,7 @@ const projectCollection = defineCollection({
|
||||
src: z.string(),
|
||||
height: z.number().optional(),
|
||||
width: z.number().optional(),
|
||||
aspectRatio: z.union([z.number(), z.string().regex(/^\d+:\d+$/)]),
|
||||
aspectRatio: z.number().optional(),
|
||||
})
|
||||
.optional(),
|
||||
sort: z.number().optional(),
|
||||
|
||||
@@ -16,10 +16,10 @@ const { frontmatter } = Astro.props;
|
||||
>
|
||||
<Picture
|
||||
alt="Stefan Imhoff"
|
||||
aspectRatio="1:1"
|
||||
aspect={1}
|
||||
breakpoints={[300, 512]}
|
||||
class="[&_img]:xl:-scale-x-100"
|
||||
src="/assets/images/ai-portrait-stefan-imhoff.png"
|
||||
widths={[300, 512]}
|
||||
/>
|
||||
</div>
|
||||
<slot />
|
||||
|
||||
Reference in New Issue
Block a user