Skip to content

Commit d444a69

Browse files
Improve Documentation Routing & Fix All Internal Broken Links (#185)
* 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. * 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. * Update internal desktop documentation links Corrected internal links in child-processes and status documentation to remove versioned paths, ensuring consistency and preventing broken links.
1 parent 710e454 commit d444a69

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

resources/views/docs/desktop/1/digging-deeper/child-processes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ ChildProcess::stop('tail');
189189
This will attempt to stop the process gracefully. The [`ProcessExited`](#codeprocessexitedcode) event will be
190190
dispatched if the process exits.
191191

192-
Note that [persistent processes](/docs/desktop/1/digging-deeper/child-process#persistent-processes) will be permanently stopped and will only be restarted when the `start` method is called again. If you want to restart a persistent process, use the `restart` method instead.
192+
Note that [persistent processes](/docs/digging-deeper/child-processes#persistent-processes) will be permanently stopped and will only be restarted when the `start` method is called again. If you want to restart a persistent process, use the `restart` method instead.
193193

194194
## Restarting a Child Process
195195

@@ -271,11 +271,11 @@ A Child Process may send output via any of the following interfaces:
271271
- A custom interface, e.g. a network socket.
272272
- Broadcasting a Custom Event
273273

274-
`STDOUT`, `STDERR` & [Custom Events](/docs/desktop/1/digging-deeper/broadcasting#custom-events) are dispatched using
274+
`STDOUT`, `STDERR` & [Custom Events](/docs/digging-deeper/broadcasting#custom-events) are dispatched using
275275
Laravel's event system.
276276

277277
You may listen to these events by registering a listener in your app service provider, or on the front end
278-
using the [Native helper](/docs/desktop/1/digging-deeper/broadcasting#listening-with-javascript).
278+
using the [Native helper](/docs/digging-deeper/broadcasting#listening-with-javascript).
279279

280280
Please see the [Events](#events) section for a full list of events.
281281

resources/views/docs/desktop/1/getting-started/status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ your ideas and questions through the [forum](https://github.com/orgs/nativephp/d
2222
#### Can you sponsor?
2323

2424
If you're building an app that you plan to sell,
25-
[can you sponsor the development of NativePHP](/docs/desktop/1/getting-started/sponsoring)? This will help us to continue
25+
[can you sponsor the development of NativePHP](/docs/getting-started/sponsoring)? This will help us to continue
2626
maintaining and supporting NativePHP.
2727

2828
</aside>

resources/views/docs/mobile/1/concepts/security.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ care. If you choose to store them anywhere (either in a file or
3232
## Secure Storage
3333

3434
NativePHP provides access to your users' device's native Keystore/Keychain through the
35-
[`SecureStorage`](/docs/mobile/1/apis/secure-storage) facade, which
35+
[`SecureStorage`](/docs/apis/secure-storage) facade, which
3636
allow you to store small amounts of data in a secure way.
3737

3838
The device's secure storage encrypts and decrypts data on the fly and that means you can safely rely on it to store

resources/views/docs/mobile/1/getting-started/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ NATIVEPHP_APP_VERSION_CODE="1"
7979
```
8080

8181
Find out more about these options in
82-
[Configuration](/docs/mobile/1/getting-started/configuration#codenativephp-app-idcode).
82+
[Configuration](/docs/getting-started/configuration#codenativephp-app-idcode).
8383

8484
<aside class="relative z-0 mt-5 overflow-hidden rounded-2xl bg-pink-50 px-5 ring-1 ring-black/5 dark:bg-pink-600/10">
8585

resources/views/docs/mobile/1/getting-started/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ php artisan native:run
3232
- **Examples** - Check out the [Kitchen Sink demo app](https://play.google.com/store/apps/details?id=com.nativephp.kitchensinkapp)
3333
on Android (coming soon to iOS!)
3434

35-
Ready to build your first mobile app with PHP? [Let's get started! 🚀](/docs/mobile/1/getting-started/introduction)
35+
Ready to build your first mobile app with PHP? [Let's get started! 🚀](/docs/getting-started/introduction)

routes/web.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,40 @@
3636
Route::get('blog', [ShowBlogController::class, 'index'])->name('blog');
3737
Route::get('blog/{article}', [ShowBlogController::class, 'show'])->name('article');
3838

39-
Route::redirect('/docs/{version}/{page?}', '/docs/mobile/{version}/{page?}')
40-
->where('page', '(.*)')
41-
->where('version', '[0-9]+');
42-
4339
Route::get('/docs/{platform}/{version}/{page?}', ShowDocumentationController::class)
4440
->where('page', '(.*)')
4541
->where('platform', '[a-z]+')
46-
->where('version', '[0-9]+');
42+
->where('version', '[0-9]+')
43+
->name('docs.show');
4744

4845
// Forward unversioned requests to the latest version
4946
Route::get('/docs/{page?}', function ($page = null) {
47+
$page ??= 'introduction';
5048
$version = session('viewing_docs_version', '1');
49+
$platform = session('viewing_docs_platform', 'mobile');
5150

5251
$referer = request()->header('referer');
5352

5453
// If coming from elsewhere in the docs, match the current version being viewed
5554
if (
56-
! session()->has('viewing_docs_version')
57-
&& parse_url($referer, PHP_URL_HOST) === parse_url(url('/'), PHP_URL_HOST)
55+
parse_url($referer, PHP_URL_HOST) === parse_url(url('/'), PHP_URL_HOST)
5856
&& str($referer)->contains('/docs/')
5957
) {
60-
$version = Str::before(ltrim(Str::after($referer, url('/docs/')), '/'), '/');
58+
$path = Str::after($referer, url('/docs/'));
59+
$path = ltrim($path, '/');
60+
$segments = explode('/', $path);
61+
62+
if (count($segments) >= 2 && in_array($segments[0], ['desktop', 'mobile']) && is_numeric($segments[1])) {
63+
$platform = $segments[0];
64+
$version = $segments[1];
65+
}
6166
}
6267

63-
return redirect("/docs/{$version}/{$page}");
68+
return redirect()->route('docs.show', [
69+
'platform' => $platform,
70+
'version' => $version,
71+
'page' => $page,
72+
]);
6473
})->name('docs')->where('page', '.*');
6574

6675
Route::get('/order/{checkoutSessionId}', App\Livewire\OrderSuccess::class)->name('order.success');

0 commit comments

Comments
 (0)