A Laravel Nova package for creating reusable section blocks for headless CMS API responses
iamgerwin/nova-reusable-blocks is a Laravel package for a laravel nova package for creating reusable section blocks for headless cms api responses.
It currently has 0 GitHub stars and 5 downloads on Packagist (latest version 0.0.3).
Install it with composer require iamgerwin/nova-reusable-blocks.
Discover more Laravel packages by iamgerwin
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel Nova package that provides reusable section blocks for building dynamic, headless CMS API responses. Perfect for creating flexible page layouts that can be consumed by frontend applications.
"Because sometimes your CMS needs more blocks than a Minecraft world." 🎮
You can install the package via composer:
composer require iamgerwin/nova-reusable-blocks
The package requires:
whitecube/nova-flexible-content packageIn your Nova Resource, use the Section class to add flexible content blocks:
use Iamgerwin\NovaReusableBlocks\Section;
public function fields(NovaRequest $request)
{
return [
// Other fields...
Section::all('content'), // 'content' is the database column name
// More fields...
];
}
This will add a flexible content field with all available blocks (currently includes the Carousel Banner block).
If you want to hide the "Add Blocks" button until the resource is created:
Section::all('content', hideCreate: true)
Use a different field name for your flexible content:
Section::all('page_data') // Will store in 'page_data' column
A flexible hero component supporting image, video, or carousel backgrounds. Uses MediaHub when available or falls back to Image/URL fields.
A simple hero section with title, subtitle, and description.
The Carousel Banner is a feature-rich content block that creates dynamic image carousels with customizable options.
| Option | Type | Default | Range | Description |
|--------|------|---------|-------|-------------|
| Auto Play | Boolean | true | - | Enable automatic slide progression |
| Auto Play Speed | Number | 5000ms | 1000-10000ms | Time between transitions |
| Show Navigation | Boolean | true | - | Display navigation arrows |
| Show Dots | Boolean | true | - | Display pagination dots |
| Transition Effect | Select | slide | 6 options | Animation style |
| Transition Speed | Number | 300ms | 100-2000ms | Transition duration |
| Pause on Hover | Boolean | true | - | Pause on mouse hover |
| Aspect Ratio | Select | 16:9 | 3 options | Carousel dimensions |
| Width | Select | normal_width | 2 options | Container width |
Each slide includes:
_self or _blankThe carousel data will be available in your API responses in this format:
{
"type": "carousel-banner",
"attributes": {
"slides": [
{
"layout": "carousel-slide",
"attributes": {
"slide_image": "https://example.com/image.jpg",
"title": "Welcome",
"description": "Discover amazing content",
"button_text": "Learn More",
"button_link": "https://example.com/learn",
"button_target": "_self",
"button_size": "lg",
"button_color_palette": "light",
"button_variant": "outline",
"content_position": "center",
"alt_text": "Welcome banner"
}
}
],
"banner_title": "Featured Content",
"banner_description": "Check out our latest updates",
"auto_play": true,
"auto_play_speed": 5000,
"show_navigation": true,
"show_dots": true,
"transition_effect": "slide",
"transition_speed": 300,
"pause_on_hover": true,
"aspect_ratio": "16:9",
"width": "normal_width"
}
}
Display multiple images in a gallery format. Supports MediaHub for advanced media management or falls back to text input for image URLs.
A content divider section with an image, title, subtitle, and optional CTA button. Choose between two layout options (image left or right).
Rich text content block with flexible editor support. Automatically detects and uses:
Includes optional table of contents display.
You can easily create your own blocks by extending the Section class:
use Iamgerwin\NovaReusableBlocks\Section as BaseSection;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
class CustomSection extends BaseSection
{
protected static function getDefaultBlocks(): array
{
return [
...parent::getDefaultBlocks(), // Include default blocks
static::heroBlock(),
static::testimonialBlock(),
];
}
protected static function heroBlock(): array
{
return static::registerBlock(
'Hero Section',
'hero-section',
[
Text::make('Headline', 'headline')->rules('required'),
Textarea::make('Subheadline', 'subheadline'),
Text::make('CTA Text', 'cta_text'),
Text::make('CTA Link', 'cta_link'),
]
);
}
}
Then use your custom class in your Nova Resource:
CustomSection::all('content')
The package automatically detects if you have outl1ne/nova-media-hub installed:
MediaHubField for advanced media managementImage fieldNo configuration needed—it just works!
composer test
The package uses Laravel Pint for code styling:
composer format
Run PHPStan for static analysis:
composer analyse
Please see CHANGELOG for recent changes.
Contributions are welcome! Please feel free to submit a Pull Request.
This project follows Conventional Commits for commit messages. Please read our Contributing Guide for detailed information about:
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.