-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Special characters excluded from content collection slug #11458
Comments
I believe I actually just ran into this as well. I'm trying to build a content collection for a software library that includes versioned URLs (so I can have docs for all versions). A I would love to be able to opt out of sanitizing actually-supported characters out of my slugs in some fashion. |
You can set your own custom slug on individual entries: https://docs.astro.build/en/guides/content-collections/#defining-custom-slugs I don't think we want to change our default slugging algorithm. |
Wasn’t suggesting altering any defaults, and yes I’m aware that the slug can be customized (I mentioned above that I understood this). The problem is in my case I have to do that for every single file, all to work around a slug algorithm that really isn’t documented and certainly isn’t customizable. Ideally I would be able to customize this behavior globally or within a collection so that I don’t need to override the frontmatter in every single file (which I’m having to do in a script due to my content being autogenerated). |
A global config way of doing it could work. Do you have any suggestions as to what that would look like? |
Conceptually it seems like the slug transformer takes a file path string as input, and returns a transformed string as output. If the current logic can be easily wrapped into a function of that form, then a collection level |
|
I wish I could, but I have a new baby coming any day now and I’m spread very thin atm 😅 If things settle down during my leave I may be able to pick it up in a month or two. I think the proposal sounds great though. This would really make the content collections a lot more flexible for different use cases imo. |
cc @ascorbic how does content layer treat slugs? Is it still a special thing? Is this type of request something that could be incorporated there? |
It's already handled. The |
It uses IDs instead of slugs, but you can provide a |
Ok, in that case we probably won't add an option for the v1 CC and encourage people to switch to the new API. |
Amazing! I'll be eagerly awaiting the new content layer / #11360 🚀 🙏 |
Going to close as there's nothing actionable to do here at this time. |
Am I missing something? https://stackblitz.com/edit/github-ywpupp-dkraoo |
Content layer solves this problem. The current content collections we will slowly be phased out |
I'm guessing that it truly is experimental then 😄 |
@nicolabovolato you need to move your files out of |
Thanks @ascorbic, working fine now 🙌🏼 |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
On my personal website there's among others a basic tutorial for C and one for C++.
I'm currently migrating from pages to content collections, but il looks like the
+
sign gets stripped in the slug.What's the expected result?
From what I found in the docs, there's no mention of any character stripping when generating the slug.
I think these character should be kept as it also provides better compatibility with Astro pages.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ywpupp
Participation
The text was updated successfully, but these errors were encountered: