|
116 | 116 | } |
117 | 117 |
|
118 | 118 | /* Updates the active class on nav links based on the current URL. */ |
| 119 | + function injectDrawerNav() { |
| 120 | + /* Already injected and still in the DOM — nothing to do. */ |
| 121 | + if (document.getElementById('utplsql-drawer-nav')) return; |
| 122 | + |
| 123 | + var inner = document.querySelector('.md-sidebar--primary .md-sidebar__inner'); |
| 124 | + if (!inner) return; |
| 125 | + |
| 126 | + var section = document.createElement('nav'); |
| 127 | + section.id = 'utplsql-drawer-nav'; |
| 128 | + section.setAttribute('aria-label', 'utPLSQL.org site navigation'); |
| 129 | + |
| 130 | + var heading = document.createElement('div'); |
| 131 | + heading.className = 'utplsql-drawer-heading'; |
| 132 | + heading.textContent = 'utPLSQL.org'; |
| 133 | + section.appendChild(heading); |
| 134 | + |
| 135 | + NAV.forEach(function (item) { |
| 136 | + var a = document.createElement('a'); |
| 137 | + a.href = item.url; |
| 138 | + a.textContent = item.label; |
| 139 | + section.appendChild(a); |
| 140 | + }); |
| 141 | + |
| 142 | + inner.insertBefore(section, inner.firstChild); |
| 143 | + } |
| 144 | + |
119 | 145 | function updateActiveLink() { |
120 | 146 | var bar = document.getElementById('utplsql-topbar'); |
121 | 147 | if (!bar) return; |
|
131 | 157 | if (document.getElementById('utplsql-topbar')) { |
132 | 158 | updateActiveLink(); |
133 | 159 | applyStoredScheme(); |
| 160 | + injectDrawerNav(); |
134 | 161 | return; |
135 | 162 | } |
136 | 163 |
|
|
140 | 167 | document.body.insertBefore(savedBar, document.body.firstChild); |
141 | 168 | updateActiveLink(); |
142 | 169 | applyStoredScheme(); |
| 170 | + injectDrawerNav(); |
143 | 171 | return; |
144 | 172 | } |
145 | 173 |
|
|
212 | 240 | savedBar = bar; |
213 | 241 | document.body.insertBefore(bar, document.body.firstChild); |
214 | 242 | updateActiveLink(); |
| 243 | + injectDrawerNav(); |
215 | 244 |
|
216 | 245 | /* When auto mode is active, re-apply if the OS theme changes live. */ |
217 | 246 | window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function () { |
|
0 commit comments