Skip to content

feat: add schema parsing to live collections#13763

Merged
ascorbic merged 4 commits into
live-loadersfrom
live-loader-schema
May 7, 2025
Merged

feat: add schema parsing to live collections#13763
ascorbic merged 4 commits into
live-loadersfrom
live-loader-schema

Conversation

@ascorbic

@ascorbic ascorbic commented May 7, 2025

Copy link
Copy Markdown
Contributor

Changes

Adds schema parsing to live content collections.

  • parses the returned data from getCollection and getEntry
  • updates types so that if schema is defined, collections will be typed using that rather than the loader type
  • refactors error handling and adds more checks for the config and the data

Testing

Still needs tests

Docs

Added a new error

@github-actions github-actions Bot added pkg: astro Related to the core `astro` package (scope) docs pr labels May 7, 2025
@changeset-bot

changeset-bot Bot commented May 7, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 375d854

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ascorbic
ascorbic force-pushed the live-loader-schema branch from 32750ec to 375d854 Compare May 7, 2025 10:24
@ascorbic ascorbic self-assigned this May 7, 2025

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few questions around the code. It would be great if the RFC would cover error handling


export function isAstroError(e: unknown): e is AstroError {
return e instanceof AstroError;
return e instanceof AstroError || AstroError.is(e);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the AstroError is thrown inside the content config it's not recognising it as an instance of the AstroError class, so isn't giving the nicely-formatted error messages

Comment thread packages/astro/src/content/runtime.ts
Comment thread packages/astro/src/content/runtime.ts
@ascorbic
ascorbic merged commit c072818 into live-loaders May 7, 2025
@ascorbic
ascorbic deleted the live-loader-schema branch May 7, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants