@@ -27,3 +27,84 @@ const days = await getCollection("days");
2727 ))
2828 }
2929</Layout >
30+ <script >
31+ window.addEventListener('load', function() {
32+ function checkForAnchorAndHighlight() {
33+ const currentAnchor = window.location.hash.substring(1);
34+
35+ if (!currentAnchor) return;
36+
37+ const targetElement = document.getElementById(currentAnchor);
38+
39+ const targetByName = targetElement || document.querySelector(`[name="${currentAnchor}"]`);
40+
41+ let targetH2;
42+
43+ if (targetByName && targetByName.tagName === 'H2') {
44+ targetH2 = targetByName;
45+ } else if (targetByName) {
46+ const h2InTarget = targetByName.querySelector('h2');
47+ if (h2InTarget) {
48+ targetH2 = h2InTarget;
49+ }
50+ } else {
51+ const allH2s = document.querySelectorAll('h2');
52+ for (const h2 of allH2s) {
53+ if (h2.id === currentAnchor || h2.getAttribute('name') === currentAnchor) {
54+ targetH2 = h2;
55+ break;
56+ }
57+ }
58+ }
59+
60+ if (targetH2) {
61+ const parentElement = targetH2.parentElement;
62+
63+ if (parentElement) {
64+ const originalBorder = parentElement.style.border;
65+ const originalBorderRadius = parentElement.style.borderRadius;
66+
67+ let blinkCount = 0;
68+ const maxBlinks = 5;
69+ const blinkDuration = 500; // milliseconds
70+
71+ function toggleBorder() {
72+ if (blinkCount >= maxBlinks * 2) {
73+ parentElement.style.border = originalBorder;
74+ parentElement.style.back = originalBorder;
75+ return;
76+ }
77+
78+ if (blinkCount % 2 === 0) {
79+ parentElement.style.border = '1px solid #ff9900';
80+ parentElement.style.background = 'white';
81+ } else {
82+ parentElement.style.border = originalBorder;
83+ parentElement.style.background = originalBorder;
84+ }
85+
86+ blinkCount++;
87+ setTimeout(toggleBorder, blinkDuration);
88+ }
89+
90+ toggleBorder();
91+
92+ setTimeout(function() {
93+ const scrollOffset = 200;
94+ const elementPosition = parentElement.getBoundingClientRect().top;
95+ const offsetPosition = elementPosition + window.pageYOffset - scrollOffset;
96+
97+ window.scrollTo({
98+ top: offsetPosition,
99+ behavior: 'smooth'
100+ });
101+ }, 500);
102+ }
103+ }
104+ }
105+
106+ checkForAnchorAndHighlight();
107+
108+ window.addEventListener('hashchange', checkForAnchorAndHighlight);
109+ });
110+ </script >
0 commit comments