Skip to content

Commit 45dfb54

Browse files
committed
sort docs URLs by key descending
1 parent 3b198e3 commit 45dfb54

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

app/Models/Plugin.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ public function getDocUrl(string $version = null): ?string
8585
}
8686

8787
if (filled($this->docs_urls)) {
88-
return $this->docs_urls[$version ?? array_key_last($this->docs_urls)] ?? null;
88+
$docsUrls = $this->docs_urls;
89+
krsort($docsUrls);
90+
91+
return $docsUrls[$version ?? array_key_first($docsUrls)] ?? null;
8992
}
9093

9194
return null;

resources/views/plugins/view-plugin.blade.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,16 @@ class="scroll-mt-10 text-3xl font-extrabold"
314314
Documentation
315315
</div>
316316
@if (filled($plugin->docs_urls))
317+
@php
318+
$docsUrls = $plugin->docs_urls;
319+
krsort($docsUrls);
320+
@endphp
321+
317322
<div class="flex flex-wrap items-center gap-3">
318323
<div>Version:</div>
319324
<select
320325
x-data="{
321-
selected: @js(request()->query('v') ?? array_key_last($plugin->docs_urls)),
326+
selected: @js(request()->query('v') ?? array_key_first($docsUrls)),
322327
init() {
323328
this.$watch('selected', () => {
324329
const url = new URL(window.location)
@@ -331,7 +336,7 @@ class="scroll-mt-10 text-3xl font-extrabold"
331336
x-model="selected"
332337
class="block w-32 rounded-lg border border-gray-300 bg-gray-50 p-2 text-sm text-gray-900 focus:border-salmon focus:ring-salmon"
333338
>
334-
@foreach ($plugin->docs_urls as $key => $value)
339+
@foreach ($docsUrls as $key => $value)
335340
<option value="{{ $key }}">
336341
{{ $key }}
337342
</option>

0 commit comments

Comments
 (0)