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

Rename getEntry to getEntryBySlug #2408

Closed
wants to merge 2 commits into from
Closed

Rename getEntry to getEntryBySlug #2408

wants to merge 2 commits into from

Conversation

matthewp
Copy link
Contributor

What kind of changes does this PR include?

  • New or updated content

Description

  • Based on conversations in core it was decided to rename getEntry to getEntryBySlug 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.
  • Here's the PR in core: Rename getEntry to getEntryBySlug astro#5893

@netlify
Copy link

netlify bot commented Jan 18, 2023

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 90dc2b7
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/63c865994003c30008f85406
😎 Deploy Preview https://deploy-preview-2408--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`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!

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)

@matthewp
Copy link
Contributor Author

Closing in favor of @FredKSchott's PR which has more changes.

@matthewp matthewp closed this Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants