humanmade / hm-flourish-block
Embed Flourish visualisations and stories.
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:JavaScript
Type:wordpress-plugin
pkg:composer/humanmade/hm-flourish-block
README
A WordPress block plugin for embedding Flourish data visualizations.
Setup
- Install dependencies:
npm install
- Build the block:
npm run build
- For development with automatic rebuilds:
npm start
Project Structure
src/index.js- Main entry point, registers the block with the editorsrc/style.scss- Frontend styles for the blocksrc/editor.scss- Editor-only stylesinc/blocks.php- PHP block registration and render callbackinc/namespace.php- Plugin namespace and hook setupbuild/- Compiled assets (generated by npm build)
How It Works
- The block is registered as a dynamic block, meaning it's rendered server-side by PHP
- The editor shows a placeholder since
save() => null - The Flourish embed script is registered and enqueued only once via
wp_register_script()andwp_enqueue_script()to avoid duplicates - The render callback outputs the Flourish embed HTML with the specified visualization ID