Skip to content

Commit 11a9682

Browse files
committed
page-switcher fallback
fallback to introduction when target page doesn't exist
1 parent 33c47eb commit 11a9682

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/Livewire/VersionSwitcher.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@ public function mount(array $versions)
3131

3232
public function updatedVersion()
3333
{
34+
if (! $this->pageExists($this->platform, $this->version, $this->page)) {
35+
$this->page = 'introduction';
36+
}
37+
3438
return redirect()->route('docs.show', [
3539
'platform' => $this->platform,
3640
'version' => $this->version,
3741
'page' => $this->page,
3842
]);
3943
}
44+
45+
protected function pageExists(string $platform, int $version, string $page): bool
46+
{
47+
return file_exists(resource_path("views/docs/{$platform}/{$version}/{$page}.md"));
48+
}
4049
}

0 commit comments

Comments
 (0)