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

fix: don't strip "slug" from content layer data #12168

Merged
merged 2 commits into from
Oct 9, 2024
Merged

fix: don't strip "slug" from content layer data #12168

merged 2 commits into from
Oct 9, 2024

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Oct 9, 2024

Changes

The backward compat changes had introduced a bug, where content layer collections were having their slug field stripped. This PR fixes it so it only happens for legacy collections. This bug is not present in main.

Fixes #12162

Testing

Added a test

Docs

Copy link

changeset-bot bot commented Oct 9, 2024

🦋 Changeset detected

Latest commit: 0a16aa8

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 Oct 9, 2024
@ematipico
Copy link
Member

Some tests are failing 😢

@ascorbic ascorbic requested a review from ematipico October 9, 2024 11:09
@ascorbic ascorbic merged commit 1cd3085 into next Oct 9, 2024
13 checks passed
@ascorbic ascorbic deleted the allow-slug branch October 9, 2024 11:42
@datner
Copy link

datner commented Oct 9, 2024

🎉

@jurajkapsz
Copy link
Contributor

Will this land also in Astro v4? The same issue there when using content layer <3

@ematipico
Copy link
Member

Will this land also in Astro v4? The same issue there when using content layer <3

No, because the issue was filed against Astro v5

@ascorbic
Copy link
Contributor Author

ascorbic commented Oct 9, 2024

I couldn't reproduce this on main when I was testing it, so I made it against v5.

@jurajkapsz
Copy link
Contributor

I couldn't reproduce this on main when I was testing it, so I made it against v5.

Thank you @ascorbic . I'll create a new issue with a reproduction, because I don't know if it is the exact same issue, as it concerns using slug in frontmatter.

@jurajkapsz
Copy link
Contributor

jurajkapsz commented Oct 9, 2024

I couldn't reproduce this on main when I was testing it, so I made it against v5.

I apologize, @ascorbic you are correct , in Astro v4 this is fine. Edit: I had to change the way I access the slug field, as it is now [with content layer] in the data object as a common frontmatter field.

One thing surprised me though, that a "slug"-named frontmatter field still modifies collection entry id value in Content Layer, as it was in legacy content collections. But I easily overrode this behavior with glob loader's generateId function, in my case to basically restore the entry id value provided by default, and have my slug value as well. Don't know if this is an issue, or a backwards compatibility feature, but the generateId works fine.

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.

5 participants