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

nchammas pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/spark-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 0f373e7172 Use AnchorJS to automatically generate heading anchors 
(#700)
0f373e7172 is described below

commit 0f373e7172c3b616fdf9f8c6d09f59eadcb66f62
Author: Nicholas Chammas <[email protected]>
AuthorDate: Mon Oct 26 17:24:45 2026 +0200

    Use AnchorJS to automatically generate heading anchors (#700)
    
    Right now if you look at a page on the main website like [Useful
    Developer Tools][current], you'll notice that you cannot easily click on
    a heading and get an HTML anchor that will let you link directly to that
    section. On the other hand, if you look at the [programming docs][prog],
    you'll see that you _can_ get anchor links by mousing over a heading.
    
    This discrepancy is because [the programming docs include
    AnchorJS][anch], whereas the main website does not.
    
    This PR adds AnchorJS to the main docs so readers can easily link to
    headings there like they can on the programming docs:
    
    <img width="500"
    
src="https://github.com/user-attachments/assets/b15071c2-ba83-4502-9166-e8439696df7c";
    />
    
    This adds the [latest release of AnchorJS][rel], which is 5.0.0. The
    programming docs are [on AnchorJS 1.1.1][old], which is more than 11
    years old. In a matching PR, I will update the programming docs to also
    use AnchorJS 5.0.0 so they are consistent.
    
    I built the docs locally and confirmed that the anchors work as
    expected.
    
    [current]: https://spark.apache.org/developer-tools.html
    [prog]: https://spark.apache.org/docs/latest/
    [anch]:
    
https://github.com/apache/spark/blob/392dd8dc39b2d6bb3fb341901cb27d4d7103dc34/docs/_layouts/global.html#L199
    [rel]: https://github.com/bryanbraun/anchorjs/releases
    [old]:
    
https://github.com/apache/spark/blob/44c931f006194a833f09517c9e35fb3cdf5852b1/docs/js/vendor/anchor.min.js#L2
    
    Matching AnchorJS upgrade on the docs site:
    https://github.com/apache/spark/pull/59547
---
 _layouts/global.html    | 12 +++++++++++-
 js/vendor/anchor.min.js |  9 +++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/_layouts/global.html b/_layouts/global.html
index 30cb99f6fb..c5ccc30cf7 100644
--- a/_layouts/global.html
+++ b/_layouts/global.html
@@ -158,7 +158,7 @@
 
 <div class="container">
   <div class="row mt-4">
-    <div class="col-12 col-md-9">
+    <div class="col-12 col-md-9" id="content">
       {% if page.title %}
       <h1>{{ page.title }}</h1>
       {% endif %}
@@ -217,5 +217,15 @@
 <script src="{{site.baseurl}}/js/bootstrap.bundle.min.js"></script>
 <script src="{{site.baseurl}}/js/lang-tabs.js"></script>
 <script src="{{site.baseurl}}/js/downloads.js"></script>
+{% comment %}
+Keep the version of AnchorJS used here in sync with what's used on the docs 
site.
+See: https://github.com/apache/spark/blob/master/docs/js/vendor/anchor.min.js
+{% endcomment %}
+<script src="{{site.baseurl}}/js/vendor/anchor.min.js"></script>
+<script>
+  // Display anchor links when hovering over headings.
+  // See: https://www.bryanbraun.com/anchorjs/
+  anchors.add('#content :is(h2, h3, h4, h5, h6)');
+</script>
 </body>
 </html>
diff --git a/js/vendor/anchor.min.js b/js/vendor/anchor.min.js
new file mode 100644
index 0000000000..00f80c058f
--- /dev/null
+++ b/js/vendor/anchor.min.js
@@ -0,0 +1,9 @@
+// @license 
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
+//
+// AnchorJS - v5.0.0 - 2023-01-18
+// https://www.bryanbraun.com/anchorjs/
+// Copyright (c) 2023 Bryan Braun; Licensed MIT
+//
+// @license 
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
+!function(A,e){"use strict";"function"==typeof 
define&&define.amd?define([],e):"object"==typeof 
module&&module.exports?module.exports=e():(A.AnchorJS=e(),A.anchors=new 
A.AnchorJS)}(globalThis,function(){"use strict";return function(A){function 
u(A){A.icon=Object.prototype.hasOwnProperty.call(A,"icon")?A.icon:"",A.visible=Object.prototype.hasOwnProperty.call(A,"visible")?A.visible:"hover",A.placement=Object.prototype.hasOwnProperty.call(A,"placement")?A.placement:"right",A.ariaLabel=Obje
 [...]
+// @license-end


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to