This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-website.git


The following commit(s) were added to refs/heads/master by this push:
     new e23a76426da Optimize the page anchor (#724)
e23a76426da is described below

commit e23a76426da3b4279d956370ecd755cb85a2326a
Author: Juntao Zhang <[email protected]>
AuthorDate: Wed Jun 19 07:43:35 2024 +0800

    Optimize the page anchor (#724)
---
 layouts/shortcodes/downloads-block.html |  6 ++++--
 themes/docsy/assets/js/active.js        | 10 ++++++----
 themes/docsy/layouts/docs/baseof.html   |  6 ++++--
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/layouts/shortcodes/downloads-block.html 
b/layouts/shortcodes/downloads-block.html
index f9a804aff85..5c38399fc19 100755
--- a/layouts/shortcodes/downloads-block.html
+++ b/layouts/shortcodes/downloads-block.html
@@ -12,7 +12,8 @@
       <button class="sky-btn">{{.buttonText}}</button>
     </a>
     {{else}}
-    <a href="#{{.type}}" class="link-type">
+    {{$type := replace .type " " "" }}
+    <a href="#{{$type}}" class="link-type">
       <button class="sky-btn">{{.type}}</button>
     </a>
     {{end}}
@@ -28,7 +29,8 @@
     {{if .buttonText}}
     <h2 class="deco-title" id="{{.buttonText}}">{{.type}}</h2>
     {{else}}
-    <h2 class="deco-title" id="{{.type}}">{{.type}}</h2>
+    {{$type := replace .type " " "" }}
+    <h2 class="deco-title" id="{{$type}}">{{.type}}</h2>
     {{end}}
 
     <div class="item-wrapper">
diff --git a/themes/docsy/assets/js/active.js b/themes/docsy/assets/js/active.js
index 819c8f8a484..76bb92a8a32 100644
--- a/themes/docsy/assets/js/active.js
+++ b/themes/docsy/assets/js/active.js
@@ -7,11 +7,13 @@ $(function () {
   }
 
   function bindClick() {
-    $('.title-box a').on('click', function () {
+    $('.container a').not('.link-type').on('click', function () {
       var hash = $(this).attr('href')
-      scrollTop(hash);
-      $('.card-wrapper .card').removeClass('active');
-      $(hash).parents('.card').addClass('active');
+      if (hash && /^#/.test(hash)) {
+        scrollTop(hash);
+        $('.card-wrapper .card').removeClass('active');
+        $(hash).parents('.card').addClass('active');
+      }
     });
     $('.link-type').on('click', function () {
       var hash = $(this).attr('href')
diff --git a/themes/docsy/layouts/docs/baseof.html 
b/themes/docsy/layouts/docs/baseof.html
index b293d0f3859..2f630bcc10a 100644
--- a/themes/docsy/layouts/docs/baseof.html
+++ b/themes/docsy/layouts/docs/baseof.html
@@ -27,7 +27,8 @@
                 <button class="sky-btn">{{.buttonText}}</button>
               </a>
               {{else}}
-              <a href="#{{.type}}" class="link-type">
+              {{$type := replace .type " " "" }}
+              <a href="#{{$type}}" class="link-type">
                 <button class="sky-btn">{{.type}}</button>
               </a>
               {{end}}
@@ -39,7 +40,8 @@
               {{if .buttonText}}
               <h2 class="deco-title" id="{{.buttonText}}">{{.type}}</h2>
               {{else}}
-              <h2 class="deco-title" id="{{.type}}">{{.type}}</h2>
+              {{$type := replace .type " " "" }}
+              <h2 class="deco-title" id="{{$type}}">{{.type}}</h2>
               {{end}}
 
               <div class="item-wrapper">

Reply via email to