-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rename getEntry to getEntryBySlug #2408
Conversation
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
|
||
`getEntry()` is function that returns a specific entry in a collection by entry ID (file path relative to the collection). Both of these are required parameters. | ||
`getEntryBySlug()` is function that returns a specific entry in a collection by its slug (a slug that can be used in a URL). Both of these are required parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`getEntryBySlug()` is function that returns a specific entry in a collection by its slug (a slug that can be used in a URL). Both of these are required parameters. | |
`getEntryBySlug()` is function that returns a specific entry in a collection by its slug (filename without the extension). Both of these are required parameters. |
Is this what it is? Is the slug exactly the file name (minus extension), or is it user-defined?
Saying "a slug" makes it sound like it could be up for grabs. If something defined in frontmatter, then maybe we could say something like:
(a value defined in the frontmatter)
Otherwise, the rest of the changes look good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly, if you have things like spaces those get converted to -. The slug is described more accurately in the section right after this. That's why I was being more vague here.
Could just omit the definition or link to the section below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think linking to the term below is good. Why try to figure out how to say it twice? 😄
I guess the closest heading is #data-returned-from-a-collection-query
If you'd rather, what about something like:
its slug (URL-ready)
its URL-ready slug
Does that convey it well enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think either of those work well enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with its slug (URL-ready)
Closing in favor of @FredKSchott's PR which has more changes. |
What kind of changes does this PR include?
Description
getEntry
togetEntryBySlug
to reduce the overlap between id and slug. The hope is that in the future we provide better utilities around types of collections; for example some collections are used to generate pages and should have a slug (or permalink) and some are not, in which case they should not have that.