Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Improve the navi:make command output
Browse files Browse the repository at this point in the history
🚚 Change the `make:navi` command signature to `navi:make`
Log1x committed Oct 1, 2024
1 parent 99cad96 commit 5b95f76
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/Console/NaviMakeCommand.php
Original file line number Diff line number Diff line change
@@ -41,9 +41,28 @@ public function handle()
return false;
}

$name = strtolower(trim($this->argument('name')));
$component = Str::of($this->argument('name'))
->lower()
->trim();

$this->components->info("Navi component <fg=blue><x-{$name} /></> is ready for use.");
$default = $this->option('default') ?? 'primary_navigation';

$locations = collect(get_registered_nav_menus())
->take(5)
->map(fn ($name, $slug) => $slug === $default
? "{$name}: <fg=blue><x-{$component} /></>"
: "{$name}: <fg=blue><x-{$component} name=\"{$slug}\" /></>"
);

$this->components->info("Navi component <fg=blue><x-{$component} /></> is ready for use.");

if ($locations->isEmpty()) {
$this->components->warn('Your theme does not appear to have any registered navigation menu locations.');

return;
}

$this->components->bulletList($locations->all());
}

/**

0 comments on commit 5b95f76

Please sign in to comment.