فهرست منبع

Changed: more sidebar progress

James Doyle 3 سال پیش
والد
کامیت
aa8863c0d9

+ 5 - 0
resources/css/theme-default.style.css

@@ -521,6 +521,11 @@ html {
     background: linear-gradient(180deg, rgba(0, 0, 0, .2), transparent 8px), linear-gradient(0deg, rgba(0, 0, 0, .2), transparent 8px), linear-gradient(180deg, #000, transparent 1.5px), linear-gradient(0deg, #939393, hsla(0, 0%, 58%, 0) 1.5px), #262626
 }
 
+.tocify-wrapper .jets-searching .tocify-subheader,
+.tocify-wrapper .tocify-subheader.visible {
+    display: block;
+}
+
 .tocify-wrapper .tocify-subheader .tocify-item>a {
     padding-left: 25px;
     font-size: 12px

+ 21 - 0
resources/js/theme-default.js

@@ -1,3 +1,22 @@
+function hashChange() {
+    const currentItems = document.querySelectorAll('.tocify-subheader');
+    Array.from(currentItems).forEach((elem) => {
+        elem.classList.remove('visible');
+    });
+
+    const currentTag = document.querySelector(`a[href="${window.location.hash}"]`);
+    if (currentTag) {
+        if (currentTag.parentElement.matches('.level-2')) {
+            const parent = currentTag.closest('.tocify-subheader');
+            if (parent) {
+                parent.classList.add('visible');
+            }
+        }
+    }
+}
+
+window.addEventListener('hashchange', hashChange, false);
+
 document.addEventListener('DOMContentLoaded', function() {
     window.hljs.highlightAll();
     // https://jets.js.org/
@@ -28,4 +47,6 @@ document.addEventListener('DOMContentLoaded', function() {
             z: 'ŽžżŻźŹ'
         }
     });
+
+    hashChange();
 });

+ 1 - 1
resources/views/themes/default/endpoint.blade.php

@@ -2,7 +2,7 @@
     /** @var  Knuckles\Camel\Output\OutputEndpointData $endpoint */
 @endphp
 
-<h2 id="{!! Str::slug($group['name']) !!}-{!! $endpoint->endpointId() !!}">{{ $endpoint->metadata->title ?: ($endpoint->httpMethods[0]." ".$endpoint->uri)}}</h2>
+<h2 id="{!! Str::slug($group['name']) !!}-{!! $endpoint->endpointId() !!}"><a href="#{!! Str::slug($group['name']) !!}-{!! $endpoint->endpointId() !!}">🔗</a>&nbsp;{{ $endpoint->metadata->title ?: ($endpoint->httpMethods[0]." ".$endpoint->uri)}}</h2>
 
 <p>
 @component('scribe::components.badges.auth', ['authenticated' => $endpoint->metadata->authenticated])

+ 2 - 2
resources/views/themes/default/sidebar.blade.php

@@ -1,11 +1,11 @@
 @foreach($groupedEndpoints as $group)
 <ul id="tocify-header{{ $loop->index }}" class="tocify-header">
-    <li class="tocify-item" data-unique="{!! Str::slug($group['name']) !!}">
+    <li class="tocify-item level-1" data-unique="{!! Str::slug($group['name']) !!}">
         <a href="#{!! Str::slug($group['name']) !!}">{!! $group['name'] !!}</a>
     </li>
     @foreach($group['endpoints'] as $endpoint)
     <ul class="tocify-subheader" data-tag="{{ $loop->index }}">
-        <li class="tocify-item" data-unique="{!! Str::slug($group['name']) !!}-{!! $endpoint->endpointId() !!}">
+        <li class="tocify-item level-2" data-unique="{!! Str::slug($group['name']) !!}-{!! $endpoint->endpointId() !!}">
             <a href="#{!! Str::slug($group['name']) !!}-{!! $endpoint->endpointId() !!}">{{ $endpoint->metadata->title ?: ($endpoint->httpMethods[0]." ".$endpoint->uri)}}</a>
         </li>
     </ul>