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

Improve handler() reference docs #9261

Merged
merged 3 commits into from
Aug 29, 2024
Merged

Improve handler() reference docs #9261

merged 3 commits into from
Aug 29, 2024

Conversation

delucis
Copy link
Member

@delucis delucis commented Aug 29, 2024

Description (required)

This PR improves the defineAction() reference docs to better describe the signature of the handler() option and mention the context argument.

Also took the liberty of removing the extra <Since> components on handler and input sections — felt excessive to add those when they are properties of defineAction(), which means they were added at the same time.

Copy link

netlify bot commented Aug 29, 2024

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 1780e69
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/66d0dffa703df70008c577d2
😎 Deploy Preview https://deploy-preview-9261--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.

@astrobot-houston
Copy link
Contributor

astrobot-houston commented Aug 29, 2024

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

Locale File Note
en reference/api-reference.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
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.

Amazing, thank you @delucis ! Just one comment for your suggestion, but excellent as is!

Copy link
Contributor

@ArmandPhilippot ArmandPhilippot left a comment

Choose a reason for hiding this comment

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

A concern about the example since we now show that the context is available. And some nitpicking (or quibbling... not sure about the right word, sorry).

Other than that, looks good to me! I agree that repeating the Since may not be necessary and could be unhelpful if in another version another parameter is added (it's easier to spot a new parameter if the others don't have Since).

Comment on lines +2506 to 2508
handler: async (input, context) => {
return `Hello, ${input.name}!`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a good idea to show that context is also available, but shouldn't we update the example to include context?

This is a rough draft (I haven't taken the time to familiarize myself with Actions yet to find a better example) but maybe something like:

Suggested change
handler: async (input, context) => {
return `Hello, ${input.name}!`
}
handler: async (input, context) => {
if (!input.name) context.redirect();
return `Hello, ${input.name}!`
}

Copy link
Member Author

@delucis delucis Aug 29, 2024

Choose a reason for hiding this comment

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

context.redirect() is not available on this version of context 😅

I also thought about this, but I mainly wanted to show it exists here without muddying the example. I think the reason context was excluded in the initial version is that it’s mostly for pretty advanced use cases (for example it allows you to read context.locals if you have some middleware), so I think it’s OK not to demonstrate it — just to mention its existence.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I did say that I wasn't familiar enough with this feature. 😅 It's good for me so, no need for an overly complex example!

Co-authored-by: Armand Philippot <git@armand.philippot.eu>
@delucis
Copy link
Member Author

delucis commented Aug 29, 2024

Thanks @ArmandPhilippot — nitpicking and quibbling are both correct! (You could even do both simultaneously 😁)

@delucis delucis merged commit d17c5b7 into main Aug 29, 2024
10 checks passed
@delucis delucis deleted the chris/actions-improvements branch August 29, 2024 21:01
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Aug 29, 2024
yanthomasdev added a commit that referenced this pull request Aug 30, 2024
#9260)

* i18n(fr): add Actions in `api-reference.mdx`

See #9224 and #9254

* i18n(fr): add View Transitions section in api-reference.mdx

See #9174

* i18n(fr): improve Actions handler documentation

See #9261

* i18n(fr): update `view-transitions.mdx`

See #9224

* i18n(fr): reword sentences around handler to make reading easier

* i18n(fr): fix View Transitions capitalization where legit

Co-authored-by: Thomas Bonnet <thomasbnt@protonmail.com>

---------

Co-authored-by: Thomas Bonnet <thomasbnt@protonmail.com>
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Sep 17, 2024
See withastro#9422 and it seems we missed some updates from withastro#9261
yanthomasdev added a commit that referenced this pull request Sep 17, 2024
* i18n(fr): update `api-reference.mdx`

See #9422 and it seems we missed some updates from #9261

* missing space

Co-authored-by: Thomas Bonnet <thomasbnt@protonmail.com>

---------

Co-authored-by: Thomas Bonnet <thomasbnt@protonmail.com>
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
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.

4 participants