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 cx from 'classnames';
|
||||||
|
|
||||||
import { Picture } from '@astrojs/image/components';
|
import { Picture } from 'astro-imagetools/components';
|
||||||
import type { PictureComponentLocalImageProps } from '@astrojs/image/components';
|
import type { PictureConfigOptions } from 'astro-imagetools';
|
||||||
|
|
||||||
interface Props extends PictureComponentLocalImageProps {
|
interface Props extends PictureConfigOptions {
|
||||||
class?: string;
|
class?: string;
|
||||||
noMargin?: boolean;
|
noMargin?: boolean;
|
||||||
slot?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { class: className, noMargin, ...props } = Astro.props;
|
const { class: className, noMargin, ...props } = Astro.props;
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ const { project } = Astro.props;
|
|||||||
) : (
|
) : (
|
||||||
<Picture
|
<Picture
|
||||||
alt={project.data.title}
|
alt={project.data.title}
|
||||||
aspectRatio={project.data.image.aspectRatio as number | `${number}:${number}`}
|
aspect={project.data.image.aspectRatio}
|
||||||
formats={['webp', 'avif']}
|
breakpoints={[300, 500, 700, 1000, 1200, 1500]}
|
||||||
widths={[300, 500, 700, 1000, 1200, 1500]}
|
format={['webp', 'avif']}
|
||||||
src={project.data.image.src}
|
src={project.data.image.src}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const projectCollection = defineCollection({
|
|||||||
src: z.string(),
|
src: z.string(),
|
||||||
height: z.number().optional(),
|
height: z.number().optional(),
|
||||||
width: z.number().optional(),
|
width: z.number().optional(),
|
||||||
aspectRatio: z.union([z.number(), z.string().regex(/^\d+:\d+$/)]),
|
aspectRatio: z.number().optional(),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
sort: z.number().optional(),
|
sort: z.number().optional(),
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ const { frontmatter } = Astro.props;
|
|||||||
>
|
>
|
||||||
<Picture
|
<Picture
|
||||||
alt="Stefan Imhoff"
|
alt="Stefan Imhoff"
|
||||||
aspectRatio="1:1"
|
aspect={1}
|
||||||
|
breakpoints={[300, 512]}
|
||||||
class="[&_img]:xl:-scale-x-100"
|
class="[&_img]:xl:-scale-x-100"
|
||||||
src="/assets/images/ai-portrait-stefan-imhoff.png"
|
src="/assets/images/ai-portrait-stefan-imhoff.png"
|
||||||
widths={[300, 512]}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
Reference in New Issue
Block a user