Skip to content

Commit 759d78a

Browse files
authored
Next, Previous and Edit link (#50)
1 parent 2bb0414 commit 759d78a

File tree

7 files changed

+94
-23
lines changed

7 files changed

+94
-23
lines changed

app/Http/Controllers/ShowDocumentationController.php

+19
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,25 @@ protected function getPageProperties($version, $page = null): array
8787
->setActive(\request()->path())
8888
->__toString();
8989

90+
$pageProperties['editUrl'] = "https://github.com/NativePHP/nativephp.com/tree/main/resources/views/docs/{$version}/{$page}.md";
91+
92+
// Find the next & previous page in the navigation
93+
$pageProperties['nextPage'] = null;
94+
$pageProperties['previousPage'] = null;
95+
96+
foreach ($navigation as $section) {
97+
foreach ($section['children'] as $key => $child) {
98+
if ($child['path'] === '/'.$pageProperties['pagePath']) {
99+
if (isset($section['children'][$key + 1])) {
100+
$pageProperties['nextPage'] = $section['children'][$key + 1];
101+
}
102+
if (isset($section['children'][$key - 1])) {
103+
$pageProperties['previousPage'] = $section['children'][$key - 1];
104+
}
105+
}
106+
}
107+
}
108+
90109
if (isset($pageProperties['packageName'])) {
91110
$cardFilename = '/img/docs/'.strtolower(Str::slug($pageProperties['packageName'])).'/img/card.png';
92111
$cardPath = public_path($cardFilename);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div {{ $attributes->class(['rounded-lg flex items-center p-3 mt-8 space-x-6 border
2+
text-orange-800 border-orange-300 bg-orange-50
3+
dark:text-orange-100 dark:bg-orange-900/80 dark:border-orange-600']) }}>
4+
<x-heroicon-o-shield-exclamation class="size-10 ml-3"/>
5+
<div>
6+
<p>
7+
NativePHP is currently in
8+
<a href="/docs/getting-started/status" class="font-bold italic font-mono flex-inline px-1 py-0.5 text-base bg-orange-200 dark:bg-orange-600 rounded">alpha</a>
9+
development
10+
</p>
11+
12+
<a href="https://github.com/nativephp/laravel?sponsor=1"
13+
onclick="fathom.trackEvent('beta_interest');"
14+
class="group mt-4 font-bold inline-flex items-center rounded-md px-3 py-1
15+
bg-orange-200 border border-orange-400 hover:bg-orange-300
16+
dark:bg-orange-600 dark:border-orange-400 dark:hover:bg-orange-500 dark:text-orange-100
17+
" target="_blank">
18+
Let's get to beta!
19+
<x-heroicon-o-rocket-launch class="ml-2 size-5 group-hover:hidden"/>
20+
<x-heroicon-s-rocket-launch class="hidden ml-2 size-5 group-hover:block"/>
21+
</a>
22+
</div>
23+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@props([
2+
'align' => 'left',
3+
])
4+
<div {{ $attributes->class([
5+
'flex sm:flex-row items-center gap-x-6 gap-y-4',
6+
'justify-start flex-col-reverse' => $align === 'left',
7+
'justify-center flex-col' => $align === 'center',
8+
'justify-between flex-col-reverse' => $align === 'between',
9+
'justify-end flex-col-reverse' => $align === 'right'
10+
]) }}>
11+
{{ $slot }}
12+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<a {{ $attributes->class(['
2+
border border-gray-300 dark:border-gray-700 rounded
3+
px-4 py-2
4+
hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700
5+
dark:hover:text-gray-300
6+
flex items-center gap-2
7+
text-sm
8+
']) }}>
9+
{{ $slot }}
10+
</a>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<hr {{ $attributes->class(['dark:border-gray-500']) }}>

resources/views/docs/index.blade.php

+28-22
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,8 @@
1010
<div class="text-5xl font-bold tracking-tight mb-4 text-[#00aaa6]">
1111
{{$title}}
1212
</div>
13-
<div class="rounded-lg flex items-center p-3 mt-8 space-x-6 border
14-
text-orange-800 border-orange-300 bg-orange-50
15-
dark:text-orange-100 dark:bg-orange-900/80 dark:border-orange-600">
16-
<x-heroicon-o-shield-exclamation class="size-10 ml-3"/>
17-
<div>
18-
<p>
19-
NativePHP is currently in
20-
<a href="/docs/getting-started/status" class="font-bold italic font-mono flex-inline px-1 py-0.5 text-base bg-orange-200 dark:bg-orange-600 rounded">alpha</a>
21-
development
22-
</p>
2313

24-
<a href="https://github.com/nativephp/laravel?sponsor=1"
25-
onclick="fathom.trackEvent('beta_interest');"
26-
class="group mt-4 font-bold inline-flex items-center rounded-md px-3 py-1
27-
bg-orange-200 border border-orange-400 hover:bg-orange-300
28-
dark:bg-orange-600 dark:border-orange-400 dark:hover:bg-orange-500 dark:text-orange-100
29-
" target="_blank">
30-
Let's get to beta!
31-
<x-heroicon-o-rocket-launch class="ml-2 size-5 group-hover:hidden"/>
32-
<x-heroicon-s-rocket-launch class="hidden ml-2 size-5 group-hover:block"/>
33-
</a>
34-
</div>
35-
</div>
14+
<x-alert-beta/>
3615

3716
@if (count($tableOfContents) > 0)
3817
<ul class="mt-8 space-y-2 block xl:hidden">
@@ -47,6 +26,33 @@ class="group mt-4 font-bold inline-flex items-center rounded-md px-3 py-1
4726
<div class="mt-8 prose dark:prose-invert">
4827
{!! $content !!}
4928
</div>
29+
30+
<x-separator class="mt-8 -mr-4 -ml-4"/>
31+
32+
@php $linkAlign = $previousPage === null ? 'right' : 'between'; @endphp
33+
<x-flex-list-of-links align="{{$linkAlign}}" class="mt-8">
34+
@if($previousPage !== null)
35+
<x-link-button href="{{ $previousPage['path'] }}">
36+
<span class="md:hidden">Previous page: </span>
37+
<span aria-hidden="true" class="hidden sm:inline">&larr;</span>
38+
<span>{{ $previousPage['title'] }}</span>
39+
</x-link-button>
40+
@endif
41+
@if($nextPage !== null)
42+
<x-link-button href="{{ $nextPage['path'] }}">
43+
<span class="md:hidden">Next page: </span>
44+
<span>{{ $nextPage['title'] }}</span>
45+
<span aria-hidden="true" class="hidden sm:inline"> &rarr;</span>
46+
</x-link-button>
47+
@endif
48+
</x-flex-list-of-links>
49+
50+
<x-separator class="mt-8 -mr-4 -ml-4"/>
51+
<div class="mt-8 text-center">
52+
<a href="{{ $editUrl }}" target="_blank" rel="noopener noreferrer" class="text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">
53+
Edit this page on GitHub
54+
</a>
55+
</div>
5056
</div>
5157
<div class="hidden max-h-[calc(100%-134px)] overflow-y-auto
5258
xl:fixed xl:right-[max(0px,calc(50%-48rem))] xl:block xl:py-8 xl:px-4 xl:pr-3 xl:w-full xl:max-w-sm">

resources/views/docs/navigation.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
x-transition:leave="transition ease-in duration-150"
1818
x-transition:leave-start="translate-y-0 opacity-100"
1919
x-transition:leave-end="translate-y-1 opacity-0"
20-
class="fixed top-12 left-0 z-40 w-full max-h-screen pt-10 pb-36 overflow-y-auto bg-white dark:bg-gray-700 mt-2 px-4 pt-4 border-b border-[#00aaa6] border-opacity-50 dark:border-opacity-90">
20+
class="fixed top-12 left-0 z-40 w-full max-h-screen pt-10 pb-36 overflow-y-auto bg-white dark:bg-gray-700 mt-2 px-4 border-b border-[#00aaa6] border-opacity-50 dark:border-opacity-90">
2121
{!! $navigation !!}
2222
</nav>

0 commit comments

Comments
 (0)