Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content Collections: remove data and body from custom slug() #5921

Closed
wants to merge 4 commits into from

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented Jan 20, 2023

Changes

  • Removes data and body from the custom slug() configuration option

Why remove this?

Allowing access to the parsed Zod schema introduces a bottleneck when looking up entries by slug. Today, this function is slower than we'd like it to be, since it needs to look through all items in a collection to give you the right one. By allowing access to the data object, it is more difficult (though not impossible) to make this function more performant in a non-breaking way.

We recognize the usefulness of looking up entries by custom data attributes. However, for the most performant and futureproof story in Astro 2.0, removing this to revisit in a future minor feels like the best path.

Testing

Update tests expecting data

Docs

TODO: docs updates

@changeset-bot
Copy link

changeset-bot bot commented Jan 20, 2023

🦋 Changeset detected

Latest commit: f824fe4

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 20, 2023
Copy link
Member

@FredKSchott FredKSchott left a comment

Choose a reason for hiding this comment

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

LGTM once you fix tests

@bholmesdev
Copy link
Contributor Author

Closing in favor of #5941

@bholmesdev bholmesdev closed this Jan 23, 2023
@bluwy bluwy deleted the feat/remove-data-from-slug-mapper branch October 8, 2024 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants