humanmade / humanmade/block-editor-ssr
Using `register_block_type_from_metadata` requires extra filter
- Dominant language
- JavaScript
- Stars
- 37
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Thank you so much for this! I've been trying to build something similar on my own but not having much success.
If you use `register_block_type_from_metadata` to register a block it does property mappings and will discard any value passed in for ssr (see line 230 in `wp-includes/blocks.php`).
To get around this I added this filter.
```
add_filter(
'block_type_metadata_settings',
function( $settings, $metadata ) {
if ( isset( $metadata['ssr'] ) && $metadata['ssr'] == true ) {
$settings['ssr'] = true;
}
return $settings;
},
10,
2
);
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading register_block_type_from_metadata and the property mapping at line 230 of wp-includes/blocks.php, then inspect the block_type_metadata_settings filter behavior. Verify that an ssr value supplied through block metadata is not discarded during registration, and add coverage for the affected path if the repository provides a relevant test location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100