Provide documentation on generating custom IDs using the glob loader #10703
Labels
add new content
Document something that is not in docs. May require testing, confirmation, or affect other pages.
📚 Subject area/topic
Content Collections
📋 Page(s) affected (or suggested, for new content)
https://docs.astro.build/en/guides/content-collections/
📋 Description of content that is out-of-date or incorrect
The
glob
loader generates IDs automatically based on the file path, but transforms those to lowercase and applies some other custom replacements:https://github.com/withastro/astro/blob/c30070b9271e4c494e7cbf3a1c45515782034911/packages/astro/src/content/loaders/glob.ts#L35-L46
https://github.com/withastro/astro/blob/1072c76703b725919cf52f63cf254a3fba90c030/packages/astro/src/content/utils.ts#L403-L408
This is a breaking change from the behaviour of the
slug
property in Astro 4.The
glob
loader accepts agenerateId
function to customize the way those IDs are generated, but that argument isn't documented anywhere. The page on Content Collections should be expanded:generateId
function, preferably with some example code.For example, to retain uppercase letters in the ID, I used this:
🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
No response
The text was updated successfully, but these errors were encountered: