From 9ff38bd6ce45594866a846d889583a3884ee0877 Mon Sep 17 00:00:00 2001 From: Moiz Haider Date: Fri, 18 Jul 2025 09:36:47 +0500 Subject: [PATCH 1/3] Improve docs routing with platform and version detection Refactored documentation routes to use named route and better handle platform and version detection from referer. The redirect now supports both platform and version, improving navigation consistency for users switching between documentation pages. --- routes/web.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/routes/web.php b/routes/web.php index 8a6a594..dadaa24 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,31 +36,40 @@ Route::get('blog', [ShowBlogController::class, 'index'])->name('blog'); Route::get('blog/{article}', [ShowBlogController::class, 'show'])->name('article'); -Route::redirect('/docs/{version}/{page?}', '/docs/mobile/{version}/{page?}') - ->where('page', '(.*)') - ->where('version', '[0-9]+'); - Route::get('/docs/{platform}/{version}/{page?}', ShowDocumentationController::class) ->where('page', '(.*)') ->where('platform', '[a-z]+') - ->where('version', '[0-9]+'); + ->where('version', '[0-9]+') + ->name('docs.show'); // Forward unversioned requests to the latest version Route::get('/docs/{page?}', function ($page = null) { + $page ??= 'introduction'; $version = session('viewing_docs_version', '1'); + $platform = session('viewing_docs_platform', 'mobile'); $referer = request()->header('referer'); // If coming from elsewhere in the docs, match the current version being viewed if ( - ! session()->has('viewing_docs_version') - && parse_url($referer, PHP_URL_HOST) === parse_url(url('/'), PHP_URL_HOST) + parse_url($referer, PHP_URL_HOST) === parse_url(url('/'), PHP_URL_HOST) && str($referer)->contains('/docs/') ) { - $version = Str::before(ltrim(Str::after($referer, url('/docs/')), '/'), '/'); + $path = Str::after($referer, url('/docs/')); + $path = ltrim($path, '/'); + $segments = explode('/', $path); + + if (count($segments) >= 2 && in_array($segments[0], ['desktop', 'mobile']) && is_numeric($segments[1])) { + $platform = $segments[0]; + $version = $segments[1]; + } } - return redirect("/docs/{$version}/{$page}"); + return redirect()->route('docs.show', [ + 'platform' => $platform, + 'version' => $version, + 'page' => $page, + ]); })->name('docs')->where('page', '.*'); Route::get('/order/{checkoutSessionId}', App\Livewire\OrderSuccess::class)->name('order.success'); From 3717f5ac75c324e49c1d45bc2b1928fa8f7938d4 Mon Sep 17 00:00:00 2001 From: Moiz Haider Date: Fri, 18 Jul 2025 09:37:13 +0500 Subject: [PATCH 2/3] Update internal mobile documentation links Corrected internal links in security, installation, and quick-start docs to point to updated paths outside the mobile/1 subdirectory for consistency and accuracy. --- resources/views/docs/mobile/1/concepts/security.md | 2 +- resources/views/docs/mobile/1/getting-started/installation.md | 2 +- resources/views/docs/mobile/1/getting-started/quick-start.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/views/docs/mobile/1/concepts/security.md b/resources/views/docs/mobile/1/concepts/security.md index 84e10a3..fcb2e77 100644 --- a/resources/views/docs/mobile/1/concepts/security.md +++ b/resources/views/docs/mobile/1/concepts/security.md @@ -32,7 +32,7 @@ care. If you choose to store them anywhere (either in a file or ## Secure Storage NativePHP provides access to your users' device's native Keystore/Keychain through the -[`SecureStorage`](/docs/mobile/1/apis/secure-storage) facade, which +[`SecureStorage`](/docs/apis/secure-storage) facade, which allow you to store small amounts of data in a secure way. The device's secure storage encrypts and decrypts data on the fly and that means you can safely rely on it to store diff --git a/resources/views/docs/mobile/1/getting-started/installation.md b/resources/views/docs/mobile/1/getting-started/installation.md index 0882ac6..3c8b847 100644 --- a/resources/views/docs/mobile/1/getting-started/installation.md +++ b/resources/views/docs/mobile/1/getting-started/installation.md @@ -79,7 +79,7 @@ NATIVEPHP_APP_VERSION_CODE="1" ``` Find out more about these options in -[Configuration](/docs/mobile/1/getting-started/configuration#codenativephp-app-idcode). +[Configuration](/docs/getting-started/configuration#codenativephp-app-idcode).