Skip to content

Commit

Permalink
[i18nIgnore] feat(image-service-reference): Change types to Uint8Array (
Browse files Browse the repository at this point in the history
#5326)

Co-authored-by: Sarah Rainsberger <[email protected]>
  • Loading branch information
Princesseuh and sarah11918 authored Nov 9, 2023
1 parent 364fc8f commit e476b10
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/content/docs/en/reference/image-service-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const service: LocalImageService = {
quality: params.get('q'),
};
},
transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig): { data: Buffer, format: OutputFormat } {
transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig): { data: Uint8Array, format: OutputFormat } {
const { buffer } = mySuperLibraryThatEncodesImages(options);
return {
data: buffer,
Expand Down Expand Up @@ -197,7 +197,7 @@ This hook parses the generated URLs by `getURL()` back into an object with the d

**Required for local services only; unavailable for external services**

`transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Buffer, format: OutputFormat }`
`transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Uint8Array, format: OutputFormat }`

This hook transforms and returns the image and is called during the build to create the final asset files.

Expand All @@ -214,7 +214,7 @@ This hook returns all additional attributes used to render the image as HTML, ba
### `getSrcSet()`
<Since v="3.3.0" /> <Badge>Experimental</Badge>

**Optional for both local and external services.**
**Optional for both local and external services.**

`getSrcSet?: (options: ImageTransform, imageConfig: AstroConfig['image']): SrcSetValue[] | Promise<SrcSetValue[]>;`

Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/es/reference/image-service-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const service: LocalImageService = {
quality: params.get('q'),
};
},
transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig): { data: Buffer, format: OutputFormat } {
transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig): { data: Uint8Array, format: OutputFormat } {
const { buffer } = mySuperLibraryThatEncodesImages(options);
return {
data: buffer,
Expand Down Expand Up @@ -140,7 +140,7 @@ export const GET: APIRoute = async ({ request }) => {

const imageTransform = imageService.parseURL(new URL(request.url), imageConfig);
// ... busca la imagen de imageTransform.src y guárdala en inputBuffer
const { data, format } = await imageService.transform(inputBuffer, imageTransform, imageConfig);
const { data, format } = await imageService.transform(inputBuffer, imageTransform, imageConfig);
return new Response(data, {
status: 200,
headers: {
Expand Down Expand Up @@ -196,7 +196,7 @@ Este hook analiza las URL generadas por `getURL()` en un objeto con las diferent

**Requerido para servicios locales; no disponible para servicios externos**

`transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Buffer, format: OutputFormat }`
`transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Uint8Array, format: OutputFormat }`

Este hook transforma y devuelve la imagen y se llama durante la compilación para crear los archivos de activos finales.

Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/zh-cn/reference/image-service-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const service: LocalImageService = {
quality: params.get('q'),
};
},
transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig): { data: Buffer, format: OutputFormat } {
transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig): { data: Uint8Array, format: OutputFormat } {
const { buffer } = mySuperLibraryThatEncodesImages(options);
return {
data: buffer,
Expand Down Expand Up @@ -196,7 +196,7 @@ export type ImageTransform = {

**仅本地服务需要;外部服务不可用**

`transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Buffer, format: OutputFormat }`
`transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Uint8Array, format: OutputFormat }`

该钩子转换并返回图像,并在构建过程中被调用以创建最终的资源文件。

Expand Down

0 comments on commit e476b10

Please sign in to comment.