Skip to content

Commit 01b0774

Browse files
committed
legacy link js added
1 parent 70b7224 commit 01b0774

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

pages/about.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
---
66
{% assign sections = site.about | sort: "section_order" %}
77

8+
89
<div class="row my-5 sticky-top">
910
<div class="col-md-3 d-none d-md-block">
1011
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
@@ -31,3 +32,52 @@
3132
{% include about-scroll-to-top.html %}
3233
</div>
3334
</div>
35+
36+
37+
<!-- Legacy anchor redirect script -->
38+
<script>
39+
document.addEventListener('DOMContentLoaded', function() {
40+
// Check if there's a hash in the URL
41+
var hash = window.location.hash;
42+
43+
// Define mappings for old anchors to new ones
44+
var anchorMappings = {
45+
'#grant': '#support',
46+
'#tool': '#components'
47+
};
48+
49+
// If the current hash matches an old anchor, redirect to the new one
50+
if (anchorMappings[hash]) {
51+
var newHash = anchorMappings[hash];
52+
53+
// Update the URL without triggering a page reload
54+
window.history.replaceState(null, null, window.location.pathname + newHash);
55+
56+
// Activate the correct tab
57+
var targetTab = document.querySelector(newHash + '-tab');
58+
var targetPane = document.querySelector(newHash);
59+
60+
if (targetTab && targetPane) {
61+
// Remove active class from all tabs and panes
62+
document.querySelectorAll('.nav-link').forEach(function(tab) {
63+
tab.classList.remove('active');
64+
tab.setAttribute('aria-selected', 'false');
65+
});
66+
document.querySelectorAll('.tab-pane').forEach(function(pane) {
67+
pane.classList.remove('active', 'show');
68+
});
69+
70+
// Activate the target tab and pane
71+
targetTab.classList.add('active');
72+
targetTab.setAttribute('aria-selected', 'true');
73+
targetPane.classList.add('active', 'show');
74+
75+
// For mobile dropdown, update selected option
76+
var mobileSelect = document.querySelector('select.nav');
77+
if (mobileSelect) {
78+
mobileSelect.value = newHash.substring(1) + '-tab';
79+
}
80+
}
81+
}
82+
});
83+
</script>

0 commit comments

Comments
 (0)