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

Updated docs to reflect that getEntry returns undefined #10688

Merged

Conversation

hkbertoson
Copy link
Contributor

Description (required)

Updated Content Collections to reflect that getEntry returns undefined.
Feedback is greatly appreciated since I am still fairly new on writing documention.

Related issues & labels (optional)

  • Closes #
  • Suggested label:

@astrobot-houston
Copy link
Contributor

astrobot-houston commented Jan 10, 2025

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/content-collections.mdx Source changed, localizations will be marked as outdated.
en/reference/modules/astro-content.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit eaed64a
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/678e554349f1b60008d9f6f0
😎 Deploy Preview https://deploy-preview-10688--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 configuration.

@sarah11918
Copy link
Member

sarah11918 commented Jan 10, 2025

Thanks for identifying an issue and bringing it up @hkbertoson

I'll ask @ascorbic to weigh in here, because I really don't love that our "basic, here's what it looks like" example has error checks and even different ways to do things in it! I don't think the guide page is the place for this unless we absolutely expect all of that to be written every time someone renders content. @ascorbic , is that really the idea?

We could have a line or section that mentions you may want to consider error handling/checking for entries, with its own separate example. Or, this just links to the reference page where we add a section on how to do this.

But, this seems wrong as "Here's how you do this!" unless this really is "how we expect you to do it, every time, checking for whether things exist first." So I'll need Matt to let me know how he wants to guide people to use the feature! Hang tight Hunter until he gives his guidance! 🙌

@hkbertoson
Copy link
Contributor Author

Sure thing. Thanks! @sarah11918

@sarah11918 sarah11918 added improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes) should this be documented? Need to figure out whether this is something to add to documentation or not labels Jan 13, 2025
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

On Talking and Doc'ing we discussed how to include this in a minimal, helpful way. We think this, plus adding to the type reference that getEntry() can returned undefined should be sufficient!

@sarah11918 sarah11918 removed the should this be documented? Need to figure out whether this is something to add to documentation or not label Jan 16, 2025
Co-authored-by: Sarah Rainsberger <[email protected]>
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Thanks so much for this great improvement @hkbertoson ! It's so appreciated that experiences from support threads make it into docs! 🙌

@sarah11918 sarah11918 added the Merge Queue Approved and ready to be merged (wait for feature release if also labelled M-O-R)! label Jan 16, 2025
@@ -147,7 +147,7 @@ const draftBlogPosts = await getCollection('blog', ({ data }) => {

<p>

**Type:** `( collection: string, id: string ) => CollectionEntry<collection> | ({ collection: string, id: string }) => CollectionEntry<collection>`
**Type:** `((collection: string, id: string) => Promise<CollectionEntry<collection> | undefined>) | (({ collection: string, id: string }) => Promise<CollectionEntry<collection> | undefined>)`
Copy link
Member

Choose a reason for hiding this comment

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

This might be too big to be legible in a single line. Do we have a multi-line syntax for types anywhere that we could replicate here?

Copy link
Member

Choose a reason for hiding this comment

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

Not really unfortunately. The usual pattern we’d follow instead would be to have something like **Type:** [`TypeName`](#typename) and show it as a type in a code block with a subheading. But usually that’s for things like options interfaces etc., not just a function type.

Copy link
Member

Choose a reason for hiding this comment

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

@ArmandPhilippot Can you think of an example off the top of your head? On desktop for me, it looks like this:

image

I think one problem is I'm not convinced that each of those two pieces will themselves fit on their own single line, so it's going to look icky either way. But, happy for someone to suggest something that they can figure out that looks good!

Copy link
Member

Choose a reason for hiding this comment

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

Also happy for any maintainer to merge once they either have improved, or resigned themselves to, the above! 😅

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I see the same thing but... not really, no. Can we drop support for Legacy collections? 😆 Another "solution" would be to use a list under Type: so that each is on its own line... (instead of the union) but that's not ideal either.

Copy link
Member

@ArmandPhilippot ArmandPhilippot Jan 16, 2025

Choose a reason for hiding this comment

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

I have a little more time than before, so I took the opportunity to take a screenshot to illustrate what I was saying:
Astro getEntry type using a list instead of an union
I don't have a strong opinion on this... I'm not sure what is more readable/understandable.

Edit: Well, it seems you also have thought about that ("on their own single line, so it's going to look icky either way.")... Not my day. 😄

Copy link
Member

Choose a reason for hiding this comment

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

I mean, I guess that's better? What does everyone think? I'm fine with 2 lines (which unfortunately looks like it's gonna be 3 in practice?) Not opposed to the bullet points here!

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, way more readable

Copy link
Member

Choose a reason for hiding this comment

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

NWTWWHB!

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

@ArmandPhilippot Happy for you to make the two line change and merge!

@ArmandPhilippot ArmandPhilippot merged commit 24ded70 into withastro:main Jan 20, 2025
10 checks passed
thomasbnt added a commit to thomasbnt/docs that referenced this pull request Jan 21, 2025
thomasbnt added a commit to thomasbnt/docs that referenced this pull request Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes) Merge Queue Approved and ready to be merged (wait for feature release if also labelled M-O-R)!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants