File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Livewire ;
4
+
5
+ use Illuminate \View \ViewException ;
6
+ use Livewire \Component ;
7
+
8
+ class VersionSwitcher extends Component
9
+ {
10
+ public string $ platform ;
11
+
12
+ public array $ versions ;
13
+
14
+ public int $ version ;
15
+
16
+ public string $ page ;
17
+
18
+ public function mount (array $ versions )
19
+ {
20
+ throw_unless (
21
+ request ()->route ()->named ('docs.show ' ),
22
+ ViewException::class,
23
+ "The version switcher can only be used on the 'docs.show' route. "
24
+ );
25
+
26
+ $ this ->platform = request ()->route ()->parameter ('platform ' );
27
+ $ this ->version = request ()->route ()->parameter ('version ' );
28
+ $ this ->page = request ()->route ()->parameter ('page ' );
29
+ $ this ->versions = $ versions ;
30
+ }
31
+
32
+ public function updatedVersion ()
33
+ {
34
+ return redirect ()->route ('docs.show ' , [
35
+ 'platform ' => $ this ->platform ,
36
+ 'version ' => $ this ->version ,
37
+ 'page ' => $ this ->page ,
38
+ ]);
39
+ }
40
+ }
Original file line number Diff line number Diff line change 4
4
</x-slot >
5
5
6
6
<x-slot name =" sidebarRight" >
7
+ {{-- Version switcher --}}
8
+ @if ($platform === ' desktop' )
9
+ <livewire:version-switcher :versions =" [
10
+ 1 => 'v1.x',
11
+ 2 => 'v2.x'
12
+ ]" />
13
+ @endif
14
+
7
15
<x-docs .toc-and-sponsors :tableOfContents =" $tableOfContents" />
8
16
</x-slot >
9
17
15
23
16
24
{{-- Table of contents --}}
17
25
<div class =" xl:hidden pt-5" >
26
+
27
+ {{-- Version switcher --}}
28
+ @if ($platform === ' desktop' )
29
+ <livewire:version-switcher :versions =" [
30
+ 1 => 'v1.x',
31
+ 2 => 'v2.x'
32
+ ]" />
33
+ @endif
34
+
18
35
{{-- Copy as Markdown Button --}}
19
36
<x-docs .copy-markdown-button class =" mt-4" />
20
37
Original file line number Diff line number Diff line change
1
+ <form wire:submit =" switch" >
2
+
3
+ <select wire:model.live =" version" name =" version" >
4
+
5
+ @foreach ($versions as $number => $label )
6
+ <option value =" {{ $number } }" >{{ $label } } </option >
7
+ @endforeach
8
+
9
+ </select >
10
+
11
+ </form >
You can’t perform that action at this time.
0 commit comments