Feature #2 : Breadcrumbs
This commit is contained in:
parent
0c2bb15b58
commit
8bfc23fa23
@ -1,18 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Foundation\Configuration\Exceptions;
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
use Illuminate\Foundation\Configuration\Middleware;
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
|
|
||||||
return Application::configure(basePath: dirname(__DIR__))
|
return Application::configure(basePath: dirname(__DIR__))
|
||||||
->withRouting(
|
->withRouting(web:
|
||||||
web: __DIR__.'/../routes/web.php',
|
__DIR__ . '/../routes/web.php',
|
||||||
commands: __DIR__.'/../routes/console.php',
|
commands: __DIR__ . '/../routes/console.php',
|
||||||
health: '/up',
|
health: '/up'
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware) {
|
->withMiddleware(function (Middleware $middleware) {
|
||||||
//
|
|
||||||
})
|
})
|
||||||
->withExceptions(function (Exceptions $exceptions) {
|
->withExceptions(function (Exceptions $exceptions) {
|
||||||
//
|
//
|
||||||
})->create();
|
})
|
||||||
|
->create();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
|
"diglactic/laravel-breadcrumbs": "^9.0",
|
||||||
"joshbrw/laravel-module-installer": "^2.0",
|
"joshbrw/laravel-module-installer": "^2.0",
|
||||||
"laravel/framework": "^11.9",
|
"laravel/framework": "^11.9",
|
||||||
"laravel/tinker": "^2.9",
|
"laravel/tinker": "^2.9",
|
||||||
|
75
config/breadcrumbs.php
Normal file
75
config/breadcrumbs.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| View Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Choose a view to display when Breadcrumbs::render() is called.
|
||||||
|
| Built in templates are:
|
||||||
|
|
|
||||||
|
| - 'breadcrumbs::bootstrap5' - Bootstrap 5
|
||||||
|
| - 'breadcrumbs::bootstrap4' - Bootstrap 4
|
||||||
|
| - 'breadcrumbs::bulma' - Bulma
|
||||||
|
| - 'breadcrumbs::foundation6' - Foundation 6
|
||||||
|
| - 'breadcrumbs::json-ld' - JSON-LD Structured Data
|
||||||
|
| - 'breadcrumbs::materialize' - Materialize
|
||||||
|
| - 'breadcrumbs::tailwind' - Tailwind CSS
|
||||||
|
| - 'breadcrumbs::uikit' - UIkit
|
||||||
|
|
|
||||||
|
| Or a custom view, e.g. '_partials/breadcrumbs'.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'view' => 'layouts.breadcrumbs',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Breadcrumbs File(s)
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The file(s) where breadcrumbs are defined. e.g.
|
||||||
|
|
|
||||||
|
| - base_path('routes/breadcrumbs.php')
|
||||||
|
| - glob(base_path('breadcrumbs/*.php'))
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'files' => base_path('routes/breadcrumbs.php'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Exceptions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Determine when to throw an exception.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// When route-bound breadcrumbs are used but the current route doesn't have a name (UnnamedRouteException)
|
||||||
|
'unnamed-route-exception' => true,
|
||||||
|
|
||||||
|
// When route-bound breadcrumbs are used and the matching breadcrumb doesn't exist (InvalidBreadcrumbException)
|
||||||
|
'missing-route-bound-breadcrumb-exception' => true,
|
||||||
|
|
||||||
|
// When a named breadcrumb is used but doesn't exist (InvalidBreadcrumbException)
|
||||||
|
'invalid-named-breadcrumb-exception' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Classes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Subclass the default classes for more advanced customisations.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Manager
|
||||||
|
'manager-class' => Diglactic\Breadcrumbs\Manager::class,
|
||||||
|
|
||||||
|
// Generator
|
||||||
|
'generator-class' => Diglactic\Breadcrumbs\Generator::class,
|
||||||
|
|
||||||
|
];
|
19
resources/views/layouts/breadcrumbs.blade.php
Normal file
19
resources/views/layouts/breadcrumbs.blade.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
@unless ($breadcrumbs->isEmpty())
|
||||||
|
<div class="flex [.header_&]:below-lg:hidden items-center gap-1.25 text-xs lg:text-sm font-medium mb-2.5 lg:mb-0" data-reparent="true" data-reparent-mode="prepend|lg:prepend" data-reparent-target="#content_container|lg:#header_container">
|
||||||
|
@foreach ($breadcrumbs as $breadcrumb)
|
||||||
|
@if (!is_null($breadcrumb->url) && !$loop->last)
|
||||||
|
<li class="breadcrumb-item"></li>
|
||||||
|
<span class="text-gray-600">
|
||||||
|
<a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a>
|
||||||
|
</span>
|
||||||
|
<i class="ki-filled ki-right text-gray-500 text-3xs">
|
||||||
|
</i>
|
||||||
|
@else
|
||||||
|
<span class="text-gray-700">
|
||||||
|
{{ $breadcrumb->title }}
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endunless
|
File diff suppressed because it is too large
Load Diff
9
routes/breadcrumbs.php
Normal file
9
routes/breadcrumbs.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php // routes/breadcrumbs.php
|
||||||
|
|
||||||
|
// Note: Laravel will automatically resolve `Breadcrumbs::` without
|
||||||
|
// this import. This is nice for IDE syntax and refactoring.
|
||||||
|
use Diglactic\Breadcrumbs\Breadcrumbs;
|
||||||
|
|
||||||
|
// This import is also not required, and you could replace `BreadcrumbTrail $trail`
|
||||||
|
// with `$trail`. This is nice for IDE type checking and completion.
|
||||||
|
use Diglactic\Breadcrumbs\Generator as BreadcrumbTrail;
|
Loading…
x
Reference in New Issue
Block a user