Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/docs/en/guides/content-collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Astro provides [two built-in loader functions](/en/reference/content-loader-refe

The [`glob()` loader](/en/reference/content-loader-reference/#glob-loader) creates entries from directories of Markdown, MDX, Markdoc, JSON, YAML, or TOML files from anywhere on the filesystem. It accepts a `pattern` of entry files to match using glob patterns supported by [micromatch](https://github.com/micromatch/micromatch#matching-features), and a base file path of where your files are located. Each entry's `id` will be automatically generated from its file name. Use this loader when you have one file per entry.

The [`file()` loader](/en/reference/content-loader-reference/#file-loader) creates multiple entries from a single local file. Each entry in the file must have a unique `id` key property. It accepts a `base` file path to your file and optionally a [`parser` function](#parser-function) for data files it cannot parse automatically. Use this loader when your data file can be parsed as an array of objects.
The [`file()` loader](/en/reference/content-loader-reference/#file-loader) creates multiple entries from a single local file. Each entry in the file must have a unique `id` key property. It accepts a `base` file path to your file and optionally a [`parser` function](#parser-function) for data files it cannot parse automatically, or to parse data asynchronously. Use this loader when your data file can be parsed as an array of objects.

```ts title="src/content.config.ts" {6,10}
import { defineCollection } from 'astro:content';
Expand Down
12 changes: 12 additions & 0 deletions src/content/docs/en/reference/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,18 @@ Specifies a number, in seconds, for which the cookie is valid.

Specifies a subpath of the domain in which the cookie is applied.

##### `partitioned`

<p>

**Type:** `boolean`<br />
<Since v="5.17.0" />
</p>

If true, the cookie is a [partitioned cookie](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Privacy_sandbox/Partitioned_cookies). Partitioned cookies can only be read within the context of the top-level site on which they were set, which allows cross-site tracking to be blocked while still enabling legitimate uses of third-party cookies.

Partitioned cookies must be set with `secure: true`.

##### `sameSite`

<p>
Expand Down
26 changes: 26 additions & 0 deletions src/content/docs/en/reference/configuration-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,19 @@ Whether to enable the Astro Dev Toolbar. This toolbar allows you to inspect your

This option is scoped to the entire project, to only disable the toolbar for yourself, run `npm run astro preferences disable devToolbar`. To disable the toolbar for all your Astro projects, run `npm run astro preferences disable devToolbar --global`.

### devToolbar.placement

<p>

**Type:** `'bottom-left' | 'bottom-center' | 'bottom-right'`<br />
**Default:** `'bottom-center'`<br />
<Since v="5.17.0" />
</p>

The default placement of the Astro Dev Toolbar on the screen.

The placement of the toolbar can still be changed via the toolbar settings UI. Once changed, the user's preference is saved in `localStorage` and overrides this configuration value.

## Prefetch Options

<p>
Expand Down Expand Up @@ -1110,6 +1123,19 @@ Whether or not to limit the size of images that the Sharp image service will pro

Set `false` to bypass the default image size limit for the Sharp image service and process large images.

#### image.service.config.kernel

<p>

**Type:** `string | undefined`<br />
**Default:** `undefined`<br />
<Since v="5.17.0" />
</p>

The default [kernel used for resizing images](https://sharp.pixelplumbing.com/api-resize/#resize) in the Sharp image service.

By default this is `undefined`, which maps to Sharp's default kernel of `lanczos3`.

### image.domains

<p>
Expand Down
35 changes: 32 additions & 3 deletions src/content/docs/en/reference/content-loader-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Astro provides two built-in loaders to help you fetch your collections. Both off

The `glob()` loader creates entries from directories of files from anywhere on the filesystem. The supported file types are Markdown, MDX, Markdoc, JSON, YAML, and TOML files.

This loader accepts an object with the following properties: `pattern`, `base` (optional), and `generateId` (optional).
This loader accepts an object with the following properties: `pattern`, `base` (optional), `generateId` (optional), and `retainBody` (optional).

```ts title="src/content.config.ts" {2,6,11,17-21}
```ts title="src/content.config.ts" {2,6,11,17-21, 27-31}
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';

Expand All @@ -44,6 +44,16 @@ const blog = defineCollection({
loader: glob({ pattern: "**/*.(md|mdx)", base: "./src/data/blog" }),
schema: /* ... */
});
const notes = defineCollection({
/* Retrieve all Markdown files in your notes directory and prevent
* the raw body of content files from being stored in the data store. */
loader: glob({
pattern: '**/*.md',
base: './src/data/notes',
retainBody: false
}),
schema: /* ... */
});
const authors = defineCollection({
/* Retrieve all JSON files in your authors directory while retaining
* uppercase letters in the ID. */
Expand Down Expand Up @@ -91,6 +101,25 @@ A callback function that returns a unique string per entry in a collection. It a

By default it uses [`github-slugger`](https://github.com/Flet/github-slugger) to generate a slug with [kebab-cased](https://developer.mozilla.org/en-US/docs/Glossary/Kebab_case) words.

#### `retainBody`

<p>

**Type:** `boolean`<br />
**Default:** `true`
<Since v="5.17.0" />
</p>

Whether or not to store the raw body of content files in the data store.

When `retainBody` is `false`, [`entry.body`](/en/reference/modules/astro-content/#body) will be `undefined` instead of containing the raw file contents.

Setting this property to `false` significantly reduces the deployed size of the data store and helps avoid hitting size limits for sites with very large collections.

For Markdown files, the rendered body will still be available in the [`entry.rendered.html` property](/en/reference/content-loader-reference/#rendered), and the [`entry.filePath` property](/en/reference/content-loader-reference/#filepath) will still point to the original file.

For MDX collections, this will dramatically reduce the size of the collection, as there will no longer be any body retained in the store.

### `file()` loader

<p>
Expand Down Expand Up @@ -143,7 +172,7 @@ An optional object with the following properties:

<p>

**Type:** `(text: string) => Record<string, Record<string, unknown>> | Array<Record<string, unknown>>`
**Type:** `(text: string) => Record<string, Record<string, unknown>> | Array<Record<string, unknown>> | Promise<Record<string, Record<string, unknown>> | Array<Record<string, unknown>>>`
</p>

A callback function to create a collection from a file’s contents. Use it when you need to process file not supported by default (e.g. `.csv`) or when using [nested `.json` documents](/en/guides/content-collections/#nested-json-documents).
Expand Down
27 changes: 27 additions & 0 deletions src/content/docs/en/reference/modules/astro-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,33 @@ fetchpriority="high"

These individual attributes can still be set manually if you need to customize them further.

#### `background`

<p>

**Type:** `string | undefined`<br />
<Since v="5.17.0" />
</p>

The background color to use when flattening an image to transform it into the requested output `format`.

By default, Sharp uses a black background when flattening an image. Specifying a different background color is especially useful when transforming images with transparent backgrounds to a format that does not support transparency (e.g. `.jpeg`):

```astro title="src/components/MyComponent.astro" "background"
---
import { Image } from 'astro:assets';
import myImage from '../assets/my_image.png';
---
<Image
src={myImage}
alt="A description of my image"
format="jpeg"
background="#ffffff"
/>
```

Values are passed directly to the image service. Sharp accepts [any value the `color-string` package can parse](https://github.com/Qix-/color-string/blob/master/README.md#parsing).

### `<Picture />`

<p><Since v="3.3.0" /></p>
Expand Down
4 changes: 3 additions & 1 deletion src/content/docs/en/reference/modules/astro-content.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,12 @@ An object of frontmatter properties inferred from your collection schema ([see `

#### `body`

**Type:** `string`
**Type:** `string | undefined`

A string containing the raw, uncompiled body of the Markdown or MDX document.

Note that if [`retainBody`](/en/reference/content-loader-reference/#retainbody) is set to `false`, this value will be `undefined` instead of containing the raw file contents.

### `CollectionKey`

<p><Since v="3.1.0" /></p>
Expand Down