Created
January 13, 2023 13:18
-
-
Save Princesseuh/71736a277b8ae0af962b6c733aa45473 to your computer and use it in GitHub Desktop.
Image Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// @ts-ignore | |
import { getImage } from '../dist/index.js'; | |
import { warnForMissingAlt } from './index.js'; | |
import type { ImgHTMLAttributes } from './index.js'; | |
import type { ImageMetadata, TransformOptions, OutputFormat } from '../dist/index.js'; | |
interface LocalImageProps | |
extends Omit<TransformOptions, 'src'>, | |
Omit<ImgHTMLAttributes, 'src' | 'width' | 'height'> { | |
src: ImageMetadata | Promise<{ default: ImageMetadata }>; | |
/** Defines an alternative text description of the image. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel). */ | |
alt: string; | |
} | |
interface RemoteImageProps extends TransformOptions, astroHTML.JSX.ImgHTMLAttributes { | |
src: string; | |
/** Defines an alternative text description of the image. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel). */ | |
alt: string; | |
format?: OutputFormat; | |
width: number; | |
height: number; | |
} | |
export type Props = LocalImageProps | RemoteImageProps; | |
const { loading = 'lazy', decoding = 'async', ...props } = Astro.props as Props; | |
if (props.alt === undefined || props.alt === null) { | |
warnForMissingAlt(); | |
} | |
const attrs = await getImage(props); | |
--- | |
<img {...attrs} {loading} {decoding} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-ignore | |
import type { ImageMetadata,OutputFormat,TransformOptions } from '../dist/index.js'; | |
import { getImage } from '../dist/index.js'; | |
import type { ImgHTMLAttributes } from './index.js'; | |
import { warnForMissingAlt } from './index.js'; | |
interface LocalImageProps | |
extends Omit<TransformOptions, 'src'>, | |
Omit<ImgHTMLAttributes, 'src' | 'width' | 'height'> { | |
src: ImageMetadata | Promise<{ default: ImageMetadata }>; | |
/** Defines an alternative text description of the image. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel). */ | |
alt: string; | |
} | |
interface RemoteImageProps extends TransformOptions, astroHTML.JSX.ImgHTMLAttributes { | |
src: string; | |
/** Defines an alternative text description of the image. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel). */ | |
alt: string; | |
format?: OutputFormat; | |
width: number; | |
height: number; | |
} | |
export type Props = LocalImageProps | RemoteImageProps; | |
const { loading = 'lazy', decoding = 'async', ...props } = Astro.props as Props; | |
if (props.alt === undefined || props.alt === null) { | |
warnForMissingAlt(); | |
} | |
const attrs = await getImage(props); | |
<Fragment> | |
<img {...attrs} loading={loading} decoding={decoding}/> | |
</Fragment> | |
export default function Image__AstroComponent_(_props: Record<string, any>): any {} | |
//# sourceMappingURL=data:application/json;charset=utf-8;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiZmlsZTovLy9Vc2Vycy9lcmlrYS9Qcm9qZWN0cy9UZW1wL2ltYWdlLWV4cGxvcmF0aW9ucy9hc3Ryby1pbWFnZXMvbm9kZV9tb2R1bGVzLy5wbnBtLyU0MGFzdHJvanMlMkJpbWFnZSU0MDAuMTIuMS9ub2RlX21vZHVsZXMvJTQwYXN0cm9qcy9pbWFnZS9jb21wb25lbnRzL0ltYWdlLmFzdHJvIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyItLS1cbi8vIEB0cy1pZ25vcmVcbmltcG9ydCB0eXBlIHsgSW1hZ2VNZXRhZGF0YSxPdXRwdXRGb3JtYXQsVHJhbnNmb3JtT3B0aW9ucyB9IGZyb20gJy4uL2Rpc3QvaW5kZXguanMnO1xuaW1wb3J0IHsgZ2V0SW1hZ2UgfSBmcm9tICcuLi9kaXN0L2luZGV4LmpzJztcbmltcG9ydCB0eXBlIHsgSW1nSFRNTEF0dHJpYnV0ZXMgfSBmcm9tICcuL2luZGV4LmpzJztcbmltcG9ydCB7IHdhcm5Gb3JNaXNzaW5nQWx0IH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Q0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3BELENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3JCLENBQUM7QUFDRDtBQUNBLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3BDLEFBQUcsQUFqQ0g7QUFBQTtBQW1DQSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUUsT0FBRCxFQUFDLE9BQU8sQ0FBQyxDQUFFLFFBQUQsRUFBQyxRQUFRLENBQUMsRUFBRztBQUN2QyxBQXBDQTtBQUFBOyIsCiAgIm5hbWVzIjogW10KfQ== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
// @ts-ignore | |
import type { ImageMetadata,OutputFormat,TransformOptions } from '../dist/index.js'; | |
import { getImage } from '../dist/index.js'; | |
import type { ImgHTMLAttributes } from './index.js'; | |
import { warnForMissingAlt } from './index.js'; | |
interface LocalImageProps | |
extends Omit<TransformOptions, 'src'>, | |
Omit<ImgHTMLAttributes, 'src' | 'width' | 'height'> { | |
src: ImageMetadata | Promise<{ default: ImageMetadata }>; | |
/** Defines an alternative text description of the image. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel). */ | |
alt: string; | |
} | |
interface RemoteImageProps extends TransformOptions, astroHTML.JSX.ImgHTMLAttributes { | |
src: string; | |
/** Defines an alternative text description of the image. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel). */ | |
alt: string; | |
format?: OutputFormat; | |
width: number; | |
height: number; | |
} | |
export type Props = LocalImageProps | RemoteImageProps; | |
const { loading = 'lazy', decoding = 'async', ...props } = Astro.props as Props; | |
if (props.alt === undefined || props.alt === null) { | |
warnForMissingAlt(); | |
} | |
const attrs = await getImage(props); | |
/// | |
<img {...attrs} {loading} {decoding} /> | |
type AstroGlobal = import('astro').AstroGlobal & { props: Props } | |
/** | |
* Astro global available in all contexts in .astro files | |
* | |
* [Astro documentation](https://docs.astro.build/reference/api-reference/#astro-global) | |
*/ | |
declare const Astro: Readonly<AstroGlobal>; | |
export default function Image__AstroComponent_(_props: Props): any {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment