This content originally appeared on DEV Community and was authored by Sarah Siqueira
The inspiration for this block came from a feature available in my portfolio built with React. This feature displays my public repositories in GitHub.
The present block does basically the same thing, but instead of React and Javascript, some code was rewritten in PHP. as it became a dynamic block.
Dynamic Blocks
Creating a Gutenberg Block whose purpose is mainly styling and HTML generation can be done only with Javascript. But for other features like displaying posts, doing remote API calls, etc, it's a better approach to render the block using PHP and not JavaScript.
To achieve that, we added the argument render_callback to the register_block_type function. That will handle the output of the block, superseding the most common javascript save/frontend function in the /src/index.js file.
Using Gihut API
You can easily display a list with public repositories of any GitHub user using the GitHub API.
This content originally appeared on DEV Community and was authored by Sarah Siqueira

Sarah Siqueira | Sciencx (2023-04-25T20:11:51+00:00) Gutenberg Block to retrieve GitHub public repositories (and enhance a portfolio). Retrieved from https://www.scien.cx/2023/04/25/gutenberg-block-to-retrieve-github-public-repositories-and-enhance-a-portfolio/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.