Skip to content

Commit 5a08fa2

Browse files
authored
fix: add stub for getLiveCollection in non-live contexts (#14109)
1 parent e7dd4e1 commit 5a08fa2

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.changeset/major-games-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Throw a more helpful error if defineLiveCollection is used outside of a live.config file

packages/astro/src/content/runtime.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,3 +974,12 @@ export function defineCollection(config: any) {
974974
}
975975
return defineCollectionOrig(config);
976976
}
977+
978+
export function defineLiveCollection() {
979+
throw new AstroError({
980+
...AstroErrorData.LiveContentConfigError,
981+
message: AstroErrorData.LiveContentConfigError.message(
982+
'Live collections must be defined in a `src/live.config.ts` file.',
983+
),
984+
});
985+
}

packages/astro/templates/content/module.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
createReference,
1212
} from 'astro/content/runtime';
1313

14-
export { defineCollection, renderEntry as render } from 'astro/content/runtime';
14+
export { defineCollection, defineLiveCollection, renderEntry as render } from 'astro/content/runtime';
1515
export { z } from 'astro/zod';
1616

1717
/* @@LIVE_CONTENT_CONFIG@@ */

0 commit comments

Comments
 (0)