[go: nahoru, domu]

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

Document how to extend integration hooks #8701

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Fryuni
Copy link
Member
@Fryuni Fryuni commented Jun 28, 2024

Description

@Fryuni Fryuni self-assigned this Jun 28, 2024
Copy link
vercel bot commented Jun 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 6:11pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs-i18n ⬜️ Ignored (Inspect) Jul 8, 2024 6:11pm

@Fryuni Fryuni added the minor-release For the next minor release; in the milestone, "merge queue" when approved by Sarah! label Jun 28, 2024
@astrobot-houston
Copy link
Contributor
astrobot-houston commented Jun 28, 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/integrations-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.

@Fryuni Fryuni requested a review from sarah11918 June 28, 2024 06:01
@sarah11918 sarah11918 added add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) labels Jun 28, 2024
Copy link
Member
@delucis delucis left a comment

Choose a reason for hiding this comment

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

Thanks Luiz! Left some notes.

src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved

```ts
// your-integration/index.ts
import './types.ts';
Copy link
Member

Choose a reason for hiding this comment

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

Realised we kind of skim over this import. Maybe should be mentioned in the introduction that this is needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit complicated. It is not required at all; you just have to have some way for the consumer integration to load the type augmentation from the provider integration, and this makes it the most intuitive (by just importing the integration).

But there are multiple ways of doing it and IMHO none of them are intuitive for non-TS-power-users

Copy link
Member

Choose a reason for hiding this comment

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

This is in the integration code itself though. If it’s not needed, maybe we remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I wasn't clear. Loading the type augmentation is required, but it isn't required to be done this way.

I'll explain this in the text

@sarah11918
Copy link
Member

Hey @Fryuni , thanks for this addition! In general, I agree with all of Chris's edits here, but I'd like your confirmation before committing them to have as a base for me to start editing.

Can you take a look over Chris's comments here and resolve them all before I do my (more text-based/structural) reviewing and possibly editing for language? Thanks! 🙌

@sarah11918 sarah11918 added this to the 4.12.0 milestone Jul 2, 2024
[skip ci]

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
[skip ci]

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
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.

Hey @Fryuni , so excited to have this feature in docs!

I've left some comments/questions, some of which are absolutely coming from a lack of familiarity with authoring integrations, so I apologize for the hand-holding I'll need.

The main takeaways here are: I'd prefer a concrete example showing an actual use case, and I'm thinking that the page hierarchy might best change here.

I think there's a case to be made for this entire section being an <h2> and the whole thing is not about "defining custom hooks" but rather "creating and using custom hooks" (As I've mentioned in one comment, maybe that means that the existing "Hooks" would be improved as "Provided Hooks" or something like that)

Anyway, process this and see what of my comments make any sense! 😄

src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
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.

I think this is looking pretty good?? In fact, when reviewing your PR initially, it kind of bothered me that we didn't say anything for Hooks, so this seems like a real improvement across the board!

Are you happy if this PR becomes just this reference documentation, or would you like to also try to fit in a recipe/guide in the same way we did for the Dev Toolbar API page?

src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
src/content/docs/en/reference/integrations-reference.mdx Outdated Show resolved Hide resolved
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@Fryuni
Copy link
Member Author
Fryuni commented Jul 8, 2024

Are you happy if this PR becomes just this reference documentation, or would you like to also try to fit in a recipe/guide in the same way we did for the Dev Toolbar API page?

I think the recipe/guide should go on a separate PR. It is not a requirement to get the feature released.

@@ -54,12 +54,18 @@ interface AstroIntegration {
logger: AstroIntegrationLogger;
}) => void | Promise<void>;
'astro:build:done'?: (options: { dir: URL; routes: RouteData[]; logger: AstroIntegrationLogger; }) => void | Promise<void>;

// ... integration-defined hooks gets added here
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
// ... integration-defined hooks gets added here
// ... any custom hooks from integrations

I like this matching the language that's already on the page. Since most people won't have to worry about this, I like this looking like, "oh, and maybe some stuff will get added here" with a direct heading ("Custom hooks") they can go see what it means, if they're curious.

};
}
```

## Hooks

Astro defines hooks that integrations can implement to execute during certain parts of Astro's lifecycle and to extend its functionality. The Astro hooks are defined in the `IntegrationHooks` interface, which is part of the global `Astro` namespace.
Copy link
Member
@sarah11918 sarah11918 Jul 9, 2024

Choose a reason for hiding this comment

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

Suggested change
Astro defines hooks that integrations can implement to execute during certain parts of Astro's lifecycle and to extend its functionality. The Astro hooks are defined in the `IntegrationHooks` interface, which is part of the global `Astro` namespace.
Astro provides hooks that integrations can implement to execute during certain parts of Astro's lifecycle to extend their functionality. Astro hooks are defined in the `IntegrationHooks` interface, which is part of the global `Astro` namespace.

I think the first sentence is nicer about the more general "providing/making available" and then the second sentence can talk about how they are technically "defined"!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" when approved by Sarah!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants