컨텐츠로 건너뛰기

Legacy flags

이 내용은 아직 번역본이 없습니다.

To help some users migrate between versions of Astro, we occasionally introduce legacy flags.

These flags allow you to opt in to some deprecated or otherwise outdated behavior of Astro in the latest version, so that you can continue to upgrade and take advantage of new Astro releases until you are able to fully update your project code.

Type: boolean
Default: false

Added in: astro@5.0.0 Beta

Enable legacy behavior for content collections (as used in Astro v2 through v4)

astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
legacy: {
collections: true
}
});

If enabled, data and content collections (only) are handled using the legacy content collections implementation. Collections with a loader (only) will continue to use the Content Layer API instead. Both kinds of collections may exist in the same project, each using their respective implementations.

The following limitations continue to exist:

  • Any legacy (type: 'content' or type: 'data') collections must continue to be located in the src/content/ directory.
  • These legacy collections will not be transformed to implicitly use the glob() loader, and will instead be handled by legacy code.
  • Collections using the Content Layer API (with a loader defined) are forbidden in src/content/, but may exist anywhere else in your project.

When you are ready to remove this flag and migrate to the new Content Layer API for your legacy collections, you must define a collection for any directories in src/content/ that you want to continue to use as a collection. It is sufficient to declare an empty collection, and Astro will implicitly generate an appropriate definition for your legacy collections:

src/content/config.ts
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({ })
export const collections = { blog };
기여하기

여러분의 생각을 들려주세요!

GitHub Issue 생성

우리에게 가장 빨리 문제를 알려줄 수 있어요.

커뮤니티