WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

Docs: Interactivity API - Create and "Interactivity API" section under "How to Guides" section and include some initial guides #62922

Open juanmaguitar opened 4 months ago

juanmaguitar commented 4 months ago

There are some guides to complement the docs at Interactivity API Reference that could be added to a new "How to Guides > Interactivity API" section

Some of the guides that could go under this new section are:

WPLake commented 4 months ago

It would be nice to highlight the fact that iAPI can be used in any theme, including classic ones. Providing a small practical example would encourage developers to apply it even while developing classic themes.

Currently, it states that the API is public but does not provide a complete example. For instance, if developers try to use the @wordpress/interactivity alias directly, it won't work because WordPress doesn't define this alias automatically when it's used out of Gutenberg blocks.

Therefore, the example should describe the way to 'enable' the alias, or at least mention that the full root path (/wp-includes/...) is necessary for usage. Otherwise, many developers might feel that using iAPI outside of Gutenberg is not expected or encouraged.

juanmaguitar commented 4 months ago

It would be nice to highlight the fact that iAPI can be used in any theme, including classic ones. Providing a small practical example would encourage developers to apply it even while developing classic themes.

@WPLake, this sounds like a great guide for the "How-to Guides > Interactivity API." Would you be up to writing this guide?

If the guide becomes too long, or it turns out to more like a tutorial, it could be suggested as a Developer Blog post and just link it from "How-to Guides > Interactivity API."

WPLake commented 4 months ago

@juanmaguitar it seems more like a simple example with a description rather than a guide. This example is included in our article within this section.

While writing the Interactivity API page, you can copy that part of the article and reword it to fit the flow of the page. The idea is to showcase that it's legimit to use in the classic themes too. Otherwise, if you copy-paste any example, it won't work due to the missing @wordpress/interactivity alias.