FEATURE Handling custom anchors and changing block icon
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2026-05-20 14:05:33 +02:00
parent b813223fcd
commit 7b27f68053
4 changed files with 25 additions and 4 deletions

View File

@ -5,15 +5,22 @@
"version": "0.1.0",
"title": "Archives des notices biographiques",
"category": "carhop-blocks",
"icon": "smiley",
"icon": "grid-view",
"description": "Archives des notices biographiques",
"supports": {
"html": false
"html": false,
"anchor": true
},
"textdomain": "carhop-blocks",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css",
"render": "file:./render.php",
"viewScript": "file:./view.js"
"viewScript": "file:./view.js",
"attributes": {
"anchor": {
"type": "string",
"default": ""
}
}
}

View File

@ -1,7 +1,9 @@
import { registerBlockType } from "@wordpress/blocks";
import "./style.scss";
import Edit from "./edit";
import save from "./save";
import metadata from "./block.json";
registerBlockType(metadata.name, {
edit: Edit,
save,
});

View File

@ -2,6 +2,8 @@
$initialPostDisplayAmount = 10;
$anchor = $attributes['anchor'] ?? false;
$args = array(
'post_type' => 'dbmob',
'posts_per_page' => $initialPostDisplayAmount,
@ -9,7 +11,7 @@ $args = array(
$query = new WP_Query($args);
$post_count = $query->found_posts;
?>
<section <?php echo get_block_wrapper_attributes(array('class' => '')); ?>>
<section <?php echo get_block_wrapper_attributes(array('class' => '', 'id' => $anchor)); ?>>
<h2>Les notices rédigées par le CARHOP</h2>
<div class="notices-toolbar" data-post-type="dbmob">

View File

@ -0,0 +1,10 @@
import { useBlockProps, RichText, InnerBlocks } from "@wordpress/block-editor";
import { __ } from "@wordpress/i18n";
export default function save({ attributes, setAttributes }) {
return (
<>
<InnerBlocks.Content />
</>
);
}