-
-
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
Updated docs to reflect that getEntry returns undefined #10688
Updated docs to reflect that getEntry returns undefined #10688
Conversation
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
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! 🙌 |
Sure thing. Thanks! @sarah11918 |
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.
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!
Co-authored-by: Sarah Rainsberger <[email protected]>
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.
Thanks so much for this great improvement @hkbertoson ! It's so appreciated that experiences from support threads make it into docs! 🙌
@@ -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>)` |
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.
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?
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 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.
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.
@ArmandPhilippot Can you think of an example off the top of your head? On desktop for me, it looks like this:
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!
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.
Also happy for any maintainer to merge once they either have improved, or resigned themselves to, the above! 😅
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 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.
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.
I have a little more time than before, so I took the opportunity to take a screenshot to illustrate what I was saying:
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. 😄
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.
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!
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.
LGTM, way more readable
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.
NWTWWHB!
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.
@ArmandPhilippot Happy for you to make the two line change and merge!
Signed-off-by: Thomas Bonnet <[email protected]>
…#10688 Signed-off-by: Thomas Bonnet <[email protected]>
…10741) Co-authored-by: Armand Philippot <[email protected]>
Co-authored-by: Armand Philippot <[email protected]>
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)