Skip to content

Commit

Permalink
Merge branch 'main' into 20240208-netlify.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
yanthomasdev authored Feb 15, 2024
2 parents fa91822 + 29f35b8 commit ed842a3
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 9 deletions.
24 changes: 21 additions & 3 deletions src/content/docs/en/guides/images.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ Use the required `alt` attribute to provide a string of [descriptive alt text](h

If an image is merely decorative (i.e. doesn't contribute to the understanding of the page), set `alt=""` so that screen readers and other assistive technologies know to ignore the image.

##### width and height (required for `public/` and remote images)
##### width and height (required for images in `public/`)

These properties define the dimensions to use for the image.

When using local images in their original aspect ratio, the `width` and `height` can be automatically inferred from the source file and are optional.
When using images in their original aspect ratio, `width` and `height` are optional. These dimensions can be automatically inferred from image files located in `src/` and from remote images with [`inferSize` set to `true`](#infersize).

However, both of these properties are required for remote images and images stored in your `public/` folder as Astro is unable to analyze these files.
However, both of these properties are required for images stored in your `public/` folder as Astro is unable to analyze these files.

##### densities

Expand Down Expand Up @@ -240,6 +240,24 @@ By default, the `<Image />` component will produce a `.webp` file.
- a preset (`low`, `mid`, `high`, `max`) that is automatically normalized between formats.
- a number from `0` to `100` (interpreted differently between formats).

##### inferSize

<p><Since v="4.4.0" /></p>

Allows you to set the original `width` and `height` of a remote image automatically.

By default, this value is set to `false` and you must manually specify both dimensions for your remote image.

Add `inferSize` to the `<Image />` component (or `inferSize: true` to `getImage()`) to infer these values from the image content when fetched. This is helpful if you don't know the dimensions of the remote image, or if they might change:

```astro mark="inferSize"
---
import { Image } from 'astro:assets';
---
<Image src="https://example.com/cat.png" inferSize alt="A cat sleeping in the sun.">
```

`inferSize` can fetch the dimensions of a [remote image from a domain that has not been authorized](#authorizing-remote-images), however the image itself will remain unprocessed.

##### Additional properties

Expand Down
1 change: 1 addition & 0 deletions src/content/docs/en/reference/error-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The following reference is a complete list of the errors you may encounter while
- [**ImageMissingAlt**](/en/reference/errors/image-missing-alt/)<br/>Image missing required "alt" property.
- [**InvalidImageService**](/en/reference/errors/invalid-image-service/)<br/>Error while loading image service.
- [**MissingImageDimension**](/en/reference/errors/missing-image-dimension/)<br/>Missing image dimensions
- [**FailedToFetchRemoteImageDimensions**](/en/reference/errors/failed-to-fetch-remote-image-dimensions/)<br/>Failed to retrieve remote image dimensions
- [**UnsupportedImageFormat**](/en/reference/errors/unsupported-image-format/)<br/>Unsupported image format
- [**UnsupportedImageConversion**](/en/reference/errors/unsupported-image-conversion/)<br/>Unsupported image conversion
- [**PrerenderDynamicEndpointPathCollide**](/en/reference/errors/prerender-dynamic-endpoint-path-collide/)<br/>Prerendered dynamic endpoint has path collision.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# NOTE: This file is auto-generated from 'scripts/error-docgen.mjs'
# Do not make edits to it directly, they will be overwritten.
# Instead, change this file: https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts
# Translators, please remove this note and the <DontEditWarning/> component.

title: Failed to retrieve remote image dimensions
i18nReady: true
githubURL: https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts
---
import DontEditWarning from '~/components/DontEditWarning.astro'

<DontEditWarning />


> Failed to get the dimensions for `IMAGE_URL`.
## What went wrong?
Determining the remote image's dimensions failed. This is typically caused by an incorrect URL or attempting to infer the size of an image in the public folder which is not possible.



Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> Missing width and height attributes for `IMAGE_URL`. When using remote images, both dimensions are always required in order to avoid cumulative layout shift (CLS).
> Missing width and height attributes for `IMAGE_URL`. When using remote images, both dimensions are required in order to avoid cumulative layout shift (CLS).
## What went wrong?
For remote images, `width` and `height` cannot be inferred from the original file. As such, in order to avoid CLS, those two properties are always required.
For remote images, `width` and `height` cannot automatically be inferred from the original file. To avoid cumulative layout shift (CLS), either specify these two properties, or set [inferSize`](/en/guides/images/#infersize) to `true` to fetch a remote image's original dimensions.

If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](/en/guides/imports/#other-assets).

**See Also:**
- [Images](/en/guides/images/)
- [Image component#width-and-height-required](/en/guides/images/#width-and-height-required-for-public-and-remote-images)
- [Image component#width-and-height-required](/en/guides/images/#width-and-height-required-for-images-in-public)


19 changes: 17 additions & 2 deletions src/content/docs/ja/reference/error-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,25 @@ githubURL: https://github.com/withastro/astro/blob/main/packages/astro/src/core/
- [**InvalidPrerenderExport**](/ja/reference/errors/invalid-prerender-export/)<br/>Invalid prerender export.
- [**InvalidComponentArgs**](/ja/reference/errors/invalid-component-args/)<br/>Invalid component arguments.
- [**PageNumberParamNotFound**](/ja/reference/errors/page-number-param-not-found/)<br/>Page number param not found.
- [**ImageMissingAlt**](/ja/reference/errors/image-missing-alt/)<br/>Missing alt property.
- [**ImageMissingAlt**](/ja/reference/errors/image-missing-alt/)<br/>Image missing required "alt" property.
- [**InvalidImageService**](/ja/reference/errors/invalid-image-service/)<br/>Error while loading image service.
- [**MissingImageDimension**](/ja/reference/errors/missing-image-dimension/)<br/>Missing image dimensions
- [**FailedToFetchRemoteImageDimensions**](/ja/reference/errors/failed-to-fetch-remote-image-dimensions/)<br/>Failed to retrieve remote image dimensions
- [**UnsupportedImageFormat**](/ja/reference/errors/unsupported-image-format/)<br/>Unsupported image format
- [**UnsupportedImageConversion**](/ja/reference/errors/unsupported-image-conversion/)<br/>Unsupported image conversion
- [**PrerenderDynamicEndpointPathCollide**](/ja/reference/errors/prerender-dynamic-endpoint-path-collide/)<br/>Prerendered dynamic endpoint has path collision.
- [**ExpectedImage**](/ja/reference/errors/expected-image/)<br/>Expected src to be an image.
- [**ExpectedImageOptions**](/ja/reference/errors/expected-image-options/)<br/>Expected image options.
- [**IncompatibleDescriptorOptions**](/ja/reference/errors/incompatible-descriptor-options/)<br/>Cannot set both `densities` and `widths`
- [**ImageNotFound**](/ja/reference/errors/image-not-found/)<br/>Image not found.
- [**NoImageMetadata**](/ja/reference/errors/no-image-metadata/)<br/>Could not process image metadata.
- [**MarkdownImageNotFound**](/ja/reference/errors/markdown-image-not-found/)<br/>Image not found.
- [**CouldNotTransformImage**](/ja/reference/errors/could-not-transform-image/)<br/>Could not transform image.
- [**ResponseSentError**](/ja/reference/errors/response-sent-error/)<br/>Unable to set response.
- [**MiddlewareNoDataOrNextCalled**](/ja/reference/errors/middleware-no-data-or-next-called/)<br/>The middleware didn't return a response or call `next`.
- [**MiddlewareNoDataOrNextCalled**](/ja/reference/errors/middleware-no-data-or-next-called/)<br/>The middleware didn't return a `Response`.
- [**MiddlewareNotAResponse**](/ja/reference/errors/middleware-not-aresponse/)<br/>The middleware returned something that is not a `Response` object.
- [**LocalsNotAnObject**](/ja/reference/errors/locals-not-an-object/)<br/>Value assigned to `locals` is not accepted.
- [**MiddlewareCantBeLoaded**](/ja/reference/errors/middleware-cant-be-loaded/)<br/>Can't load the middleware.
- [**LocalImageUsedWrongly**](/ja/reference/errors/local-image-used-wrongly/)<br/>Local images must be imported.
- [**AstroGlobUsedOutside**](/ja/reference/errors/astro-glob-used-outside/)<br/>Astro.glob() used outside of an Astro file.
- [**AstroGlobNoMatch**](/ja/reference/errors/astro-glob-no-match/)<br/>Astro.glob() did not match any files.
Expand All @@ -55,10 +60,18 @@ githubURL: https://github.com/withastro/astro/blob/main/packages/astro/src/core/
- [**FailedToLoadModuleSSR**](/ja/reference/errors/failed-to-load-module-ssr/)<br/>Could not import file.
- [**InvalidGlob**](/ja/reference/errors/invalid-glob/)<br/>Invalid glob pattern.
- [**FailedToFindPageMapSSR**](/ja/reference/errors/failed-to-find-page-map-ssr/)<br/>Astro couldn't find the correct page to render
- [**MissingLocale**](/ja/reference/errors/missing-locale/)<br/>The provided locale does not exist.
- [**MissingIndexForInternationalization**](/ja/reference/errors/missing-index-for-internationalization/)<br/>Index page not found.
- [**NoPrerenderedRoutesWithDomains**](/ja/reference/errors/no-prerendered-routes-with-domains/)<br/>Prerendered routes aren't supported when internationalization domains are enabled.
- [**CantRenderPage**](/ja/reference/errors/cant-render-page/)<br/>Astro can't render the route.
- [**UnhandledRejection**](/ja/reference/errors/unhandled-rejection/)<br/>Unhandled rejection
- [**i18nNotEnabled**](/ja/reference/errors/i18n-not-enabled/)<br/>i18n Not Enabled

## CSSエラー

- [**UnknownCSSError**](/ja/reference/errors/unknown-csserror/)<br/>Unknown CSS Error.
- [**CSSSyntaxError**](/ja/reference/errors/csssyntax-error/)<br/>CSS Syntax Error.

## Markdownエラー

- [**UnknownMarkdownError**](/ja/reference/errors/unknown-markdown-error/)<br/>Unknown Markdown Error.
Expand All @@ -68,10 +81,12 @@ githubURL: https://github.com/withastro/astro/blob/main/packages/astro/src/core/
- [**UnknownConfigError**](/ja/reference/errors/unknown-config-error/)<br/>Unknown configuration error.
- [**ConfigNotFound**](/ja/reference/errors/config-not-found/)<br/>Specified configuration file not found.
- [**ConfigLegacyKey**](/ja/reference/errors/config-legacy-key/)<br/>Legacy configuration detected.

## CLIエラー

- [**UnknownCLIError**](/ja/reference/errors/unknown-clierror/)<br/>Unknown CLI Error.
- [**GenerateContentTypesError**](/ja/reference/errors/generate-content-types-error/)<br/>Failed to generate content types.

## コンテンツコレクションエラー

- [**UnknownContentCollectionError**](/ja/reference/errors/unknown-content-collection-error/)<br/>Unknown Content Collection Error.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Prerendered routes aren't supported when internationalization domains are enabled.
i18nReady: true
githubURL: https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts
---

> **NoPrerenderedRoutesWithDomains**: 静的ページは、複数ドメインではまだサポートされていません。この機能を有効にしたい場合は、ページ「コンポーネント」に対するプリレンダリングを無効化する必要があります
## 何が問題か?

静的ページは国際化ドメインではまだサポートされていません。この機能を有効にしたい場合は、プリレンダリングを無効化する必要があります。
2 changes: 1 addition & 1 deletion src/content/docs/zh-cn/guides/content-collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,6 @@ pubDate: 2021-07-08T12:00:00-04:00
const { frontmatter } = Astro.props;
---
<h1>{frontmatter.title}</h1>
<p>{frontmatter.pubDate.slice(0,10)}</p>
<p>{frontmatter.pubDate.toString().slice(0,10)}</p>
```
要查看使用 `toLocaleDateString` 格式化日期、月份和年份的例子,请查看官方 Astro 博客模板中的 [`<FormattedDate />` 组件](https://github.com/withastro/astro/blob/latest/examples/blog/src/components/FormattedDate.astro)

0 comments on commit ed842a3

Please sign in to comment.