https://github.com/axeldotdev/content-blocks
A Laravel Nova field for flexible content blocks.
https://github.com/axeldotdev/content-blocks
Last synced: 12 months ago
JSON representation
A Laravel Nova field for flexible content blocks.
- Host: GitHub
- URL: https://github.com/axeldotdev/content-blocks
- Owner: axeldotdev
- License: mit
- Created: 2022-02-12T23:41:54.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-09T14:55:58.000Z (over 2 years ago)
- Last Synced: 2025-02-27T03:23:40.096Z (over 1 year ago)
- Language: CSS
- Homepage:
- Size: 238 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Content Blocks
[](https://packagist.org/packages/axeldotdev/content-blocks)
[](https://github.com/axeldotdev/content-blocks/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/axeldotdev/content-blocks/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
[](https://packagist.org/packages/axeldotdev/content-blocks)
[](https://packagist.org/packages/axeldotdev/content-blocks)
A Laravel Nova field for flexible content blocks.
## Installation
You can install the package via composer:
```bash
composer require --dev axeldotdev/content-blocks
```
The minimum PHP version required is **8.1**.
## Usage
You can use it like that:
```php
\Axeldotdev\ContentBlocks\ContentBlocks::make('Content')
->addButtonLabel('Add block')
->addBlock(\App\Nova\Blocks\TextBlock::class)
->addBlock(\App\Nova\Blocks\ImageBlock::class)
->addBlock(\App\Nova\Blocks\VideoBlock::class),
```
```php
// app/Nova/Blocks/TextBlock.php
namespace App\Nova\Blocks;
use Axeldotdev\ContentBlocks\Block;
class TextBlock extends Block
{
public function fields(): array
{
return [];
}
public function label(): string
{
return __('Text');
}
public function template(): string
{
return 'blocks.text';
}
public function viewData(): array
{
return [];
}
}
```
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Axel Charpentier](https://github.com/axeldotdev)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.