|
14 | 14 | name="viewport" |
15 | 15 | content="width=device-width, initial-scale=1.0, user-scalable=yes" |
16 | 16 | /> |
| 17 | + <link rel="icon" type="image/svg+xml" href="./assets/astronvim.svg" /> |
| 18 | + <link rel="shortcut icon" href="./assets/favicon.ico" /> |
| 19 | + <link rel="apple-touch-icon" href="./assets/apple-touch-icon.png" /> |
17 | 20 | $for(author-meta)$ |
18 | 21 | <meta name="author" content="$author-meta$" /> |
19 | 22 | $endfor$ $if(date-meta)$ |
|
104 | 107 | }); |
105 | 108 | }); |
106 | 109 | })(); |
107 | | - document.addEventListener('DOMContentLoaded', function () { |
| 110 | + |
| 111 | + document.addEventListener("DOMContentLoaded", function () { |
108 | 112 | const toc = document.querySelector('nav[role="doc-toc"]'); |
109 | | - const tocLinks = toc.querySelectorAll('a'); |
110 | | - const sections = Array.from(tocLinks).map(link => document.querySelector(link.getAttribute('href'))); |
| 113 | + const tocLinks = toc.querySelectorAll("a"); |
| 114 | + const sections = Array.from(tocLinks).map((link) => |
| 115 | + document.querySelector(link.getAttribute("href")), |
| 116 | + ); |
111 | 117 |
|
112 | 118 | // Scroll to specific entry on page load |
113 | 119 | const hash = window.location.hash; |
114 | 120 | if (hash) { |
115 | 121 | const target = document.querySelector(hash); |
116 | 122 | if (target) { |
117 | | - target.scrollIntoView(); |
118 | | - const activeLink = toc.querySelector('a[href="' + hash + '"]'); |
119 | | - if (activeLink) { |
120 | | - activeLink.scrollIntoView({ behavior: 'auto', block: "nearest" }); |
121 | | - } |
| 123 | + requestAnimationFrame(() => { |
| 124 | + target.scrollIntoView(); |
| 125 | + const activeLink = toc.querySelector('a[href="' + hash + '"]'); |
| 126 | + if (activeLink) { |
| 127 | + activeLink.scrollIntoView({ behavior: "auto", block: "nearest" }); |
| 128 | + } |
| 129 | + }); |
122 | 130 | } |
123 | 131 | } |
124 | 132 |
|
125 | 133 | // Observe each section |
126 | | - const observer = new IntersectionObserver(entries => { |
127 | | - entries.forEach(entry => { |
128 | | - if (entry.isIntersecting) { |
129 | | - const id = entry.target.id; |
130 | | - const activeLink = toc.querySelector('a[href="#' + id + '"]'); |
131 | | - if (activeLink) { |
132 | | - tocLinks.forEach(link => link.classList.remove('active')); |
133 | | - activeLink.classList.add('active'); |
134 | | - activeLink.scrollIntoView({ behavior: 'auto', block: "nearest" }); |
| 134 | + const observer = new IntersectionObserver( |
| 135 | + (entries) => { |
| 136 | + entries.forEach((entry) => { |
| 137 | + if (entry.isIntersecting) { |
| 138 | + const id = entry.target.id; |
| 139 | + const activeLink = toc.querySelector('a[href="#' + id + '"]'); |
| 140 | + if (activeLink) { |
| 141 | + tocLinks.forEach((link) => link.classList.remove("active")); |
| 142 | + activeLink.classList.add("active"); |
| 143 | + requestAnimationFrame(() => { |
| 144 | + activeLink.scrollIntoView({ behavior: "auto", block: "nearest" }); |
| 145 | + }); |
| 146 | + } |
135 | 147 | } |
136 | | - } |
137 | | - }); |
138 | | - }, {rootMargin: '0px 0px -60% 0px', threshold: 0.5 } ); |
| 148 | + }); |
| 149 | + }, |
| 150 | + { rootMargin: "0px 0px -60% 0px", threshold: 0.5 }, |
| 151 | + ); |
139 | 152 |
|
140 | | - sections.forEach(section => { |
| 153 | + sections.forEach((section) => { |
141 | 154 | if (section) { |
142 | 155 | observer.observe(section); |
143 | 156 | } |
|
0 commit comments