Skip to content

Commit

Permalink
Revert "Update web.php"
Browse files Browse the repository at this point in the history
This reverts commit 2814195.
  • Loading branch information
danharrin committed Jul 20, 2023
1 parent b44e61e commit ab1a30c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,30 @@
return redirect()->route('docs', ['slug' => "3.x/{$slug}"]);
}

$filePath = public_path(str_replace('//', '/', "docs/{$slug}/index.html"));
$filePath = public_path("docs/{$slug}/index.html");

if (file_exists($filePath)) {
return file_get_contents($filePath);
}

$navigation = json_decode(file_get_contents(base_path('docs/src/navigation.json')), associative: true);
$versionNavigation = $navigation[Str::before($slug, '.x') - 1];
$packageSlug = (string) str($slug)
->after('.x')
->after('/')
->before('/');

if (blank($packageSlug)) {
return redirect($versionNavigation['href']);
}

foreach ($versionNavigation['links'] as $packageNavigation) {
if ($packageNavigation['slug'] !== $packageSlug) {
continue;
}

return redirect($packageNavigation['href']);
}
// $packageSlug = (string) str($slug)
// ->after('.x')
// ->after('/')
// ->before('/');
//
// if (blank($packageSlug)) {
// return redirect($versionNavigation['href']);
// }
//
// foreach ($versionNavigation['links'] as $packageNavigation) {
// if ($packageNavigation['slug'] !== $packageSlug) {
// continue;
// }
//
// return redirect($packageNavigation['href']);
// }

return redirect($versionNavigation['href']);
})->where('slug', '.*')->name('docs');
Expand Down

0 comments on commit ab1a30c

Please sign in to comment.