yarovikov
Forum Replies Created
Viewing 5 replies - 1 through 5 (of 5 total)
-
Forum: Developing with WordPress
In reply to: registerBlockType with apiFetchThis is not sage problem. I have tried using clean wp with twentytwentyfour theme
{
"name": "wp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "wp-scripts start",
"build": "wp-scripts build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@wordpress/scripts": "^28.2.0"
}
}const defaultConfig = require('./node_modules/@wordpress/scripts/config/webpack.config.js');
const path = require('path');
module.exports = {
...defaultConfig,
entry: {
blocks: path.resolve(__dirname, 'gutenberg/blocks.js'),
},
output: {
path: path.resolve(__dirname, 'assets/build'),
filename: '[name].js',
},
optimization: {
...defaultConfig.optimization,
},
module: {
...defaultConfig.module,
},
plugins: [...defaultConfig.plugins],
};add_action('rest_api_init', function () {
register_rest_route("gutengood/v1", '/blocks', [
'methods' => 'GET',
'callback' => fn(): array => ['example', 'example-2', 'example-3'],
'permission_callback' => '__return_true',
]);
});import {registerBlockType} from '@wordpress/blocks';
import {Fragment} from '@wordpress/element';
import apiFetch from '@wordpress/api-fetch';
apiFetch({path: '/gutengood/v1/blocks'})
.then((blocks) => {
blocks.forEach(block => {
const name =gutengood/${block}
;
console.log(name)
registerBlockType(name, {
title: block,
icon: 'block-default',
category: 'common',
edit: (props) => {
return (
<Fragment>
{block}
</Fragment>
)
},
save: (props) => null,
});
});
})
.catch((error) => console.error(error?.message));the same result
screenshots
https://github.com/user-attachments/assets/a2c5f6f8-573e-4a2e-b44b-ff3522d6ea88
after edit page reload:
https://github.com/user-attachments/assets/18565498-972c-406d-8475-99dd982b855d
https://github.com/user-attachments/assets/2762a8d5-67cf-47f5-b331-b09b0d70ed00- This reply was modified 4 months, 1 week ago by yarovikov.
it is loaded. large photo is retina, thumbnails not retina
https://yarovikov.ru/wedding/photobook/client-method not work (
retina 2x not happening only for thumbnails
Viewing 5 replies - 1 through 5 (of 5 total)