den1n / nova-blog
Laravel Nova blog resources.
Installs: 883
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 3
Open Issues: 0
pkg:composer/den1n/nova-blog
Requires
- php: >=7.2
- laravel/scout: ^v8.0
- pmatseykanets/laravel-scout-postgres: ^v7.0
README
Laravel Nova blog resources.
Installation
Require package with Composer.
composer require den1n/nova-blog
Publish package resources.
php artisan vendor:publish --provider="Den1n\NovaBlog\ServiceProvider"
This will publish the following resources:
- Configuration file
config/nova-blog.php - Migration file
database/migrations/*_create_blog_tables.php - Translations
resources/lang/vendor/nova-blog - Views
resources/views/vendor/nova-blog - JavaScript assets
resources/js/vendor/nova-blog - CSS assets
resources/sass/vendor/nova-blog
Add noba-blog components provided by the package to file resources\js\app.js before Vue initialization.
require('./vendor/nova-blog');
Add noba-blog styles provided by the package to file resources\sass\app.scss.
@import './vendor/nova-blog';
Migrate database.
php artisan migrate
Add instance of class Den1n\NovaBlog\Tool to your App\Providers\NovaServiceProvider::tools() method to display the blog posts, comments, categories and tags within your Nova resources.
/** * Get the tools that should be listed in the Nova sidebar. * * @return array */ public function tools() { return [ new \Den1n\NovaBlog\Tool, ]; }
Serving Blog Posts
To serve blog posts append this route to your routes/web.php file.
Route::novaBlogRoutes();
You can define route with prefix.
Route::novaBlogRoutes('/blog');
You can get url to existing post by using Laravel route helper.
use \Den1n\NovaPosts\Models\Post; $url = route('nova-blog.post', [ 'post' => Post::find(1), ]); // Or you can pass a post slug. $url = route('nova-blog.post', [ 'post' => 'my-post-slug', ]);
Default template
Blog controller will serve posts with default template.
Template is published to views directory resources/views/vendor/nova-blog/templates/default.blade.php.
Template will receive these variables when processed:
- $post: instance of
Postmodel. - $sidebarPosts: collection of
Postmodels. - $sidebarCategories: collection of
Categorymodels. - $sidebarTags: collection of
Tagmodels.
You can freely modify default template.
Creating a custom template
First create a custom blade template in resources/views/vendor/nova-blog/templates directory.
For example, rich.blade.php.
Then register it in configuration file config/nova-blog.php.
/** * Array of templates used by controller. */ 'templates' => [ // ... [ 'name' => 'rich', 'description' => 'A rich template', ], ],
After that your custom template will be available to select when creating blog post or updating existing one.
WYSIWYG editor
By default package uses default WYSIWYG editor provided by Nova.
You can replace default editor. For example, with froala/nova-froala-field.
To do this, install the package and update editor settings in config/nova-pages.php file.
/** * Settings for WYSIWYG editor. */ 'editor' => [ /** * Nova field class name. */ 'class' => \Froala\NovaFroalaField\Froala::class, /** * Options which will be applied to te field instance. * Key: name of field method. * Value: list of method arguments. */ 'options' => [ 'withFiles' => ['public', 'nova-pages'], // Froala options. 'options' => [[ 'heightMax' => 800, 'heightMin' => 300, ]], ], ],
Screenshots
Posts
Post Form
Post Detail
Blog Example
Contributing
- Fork it.
- Create your feature branch:
git checkout -b my-new-feature. - Commit your changes:
git commit -am 'Add some feature'. - Push to the branch:
git push origin my-new-feature. - Submit a pull request.
Support
If you require any support open an issue on this repository.
License
MIT



