diff --git a/app/Livewire/Docs/Show.php b/app/Livewire/Docs/Show.php index 6c32d33..3121807 100644 --- a/app/Livewire/Docs/Show.php +++ b/app/Livewire/Docs/Show.php @@ -67,6 +67,14 @@ public function render() $menu[$doc->group][] = [ 'title' => $doc->title, 'slug' => $doc->slug, + 'sections' => request()->url() === route('docs.show', [$doc->slug]) + ? collect(explode("\n", $doc->content)) + ->filter(fn ($line) => Str::startsWith($line, '## ')) + ->map(fn ($line) => Str::after($line, '## ')) + ->mapWithKeys(fn ($section) => [$section => Str::slug($section)]) + ->map(fn ($section) => "#content-{$section}") + ->toArray() + : [], ]; } diff --git a/resources/views/livewire/docs/show.blade.php b/resources/views/livewire/docs/show.blade.php index bad004f..b265765 100644 --- a/resources/views/livewire/docs/show.blade.php +++ b/resources/views/livewire/docs/show.blade.php @@ -41,6 +41,18 @@ {{ $item['title'] }} + + @if ($item['sections']) +