|
13 | 13 | </p> |
14 | 14 | <p class="indented-block"> |
15 | 15 | <span class="project-name">tmux-python</span> |
16 | | - <a class="internal" href="https://tmuxp.git-pull.com">tmuxp</a> |
17 | | - (<a class="internal" href="https://libtmux.git-pull.com">libtmux</a>) |
| 16 | + <span class="indent"> |
| 17 | + <a class="internal" href="https://tmuxp.git-pull.com">tmuxp</a> |
| 18 | + </span> |
| 19 | + <span class="indent"> |
| 20 | + <a class="internal" href="https://libtmux.git-pull.com">libtmux</a> |
| 21 | + (<a class="internal" href="https://libtmux-mcp.git-pull.com">mcp</a>, |
| 22 | + <a class="internal" href="https://libtmux.git-pull.com/pytest-plugin/">pytest</a>) |
| 23 | + </span> |
18 | 24 | </p> |
19 | 25 |
|
20 | 26 | <p class="indented-block"> |
|
56 | 62 | <script type="text/javascript"> |
57 | 63 | (() => { |
58 | 64 | const sidebar = document.getElementById("sidebar-projects"); |
59 | | - sidebar.querySelectorAll(`a[href*="${window.location.hostname}"]`) |
60 | | - .forEach((link) => { |
61 | | - if (!link.classList.contains("active")) { |
62 | | - const d = document.createElement('span'); |
63 | | - d.textContent = link.textContent; |
64 | | - d.classList.add("active"); |
65 | | - link.parentNode.replaceChild(d, link); |
66 | | - } |
67 | | - }); |
| 65 | + const loc = window.location; |
| 66 | + sidebar.querySelectorAll("a[href]").forEach((link) => { |
| 67 | + const url = new URL(link.href, loc.origin); |
| 68 | + const sameHost = url.hostname === loc.hostname; |
| 69 | + const hasPath = url.pathname.replace(/\/+$/, "").length > 0; |
| 70 | + // Links with a pathname: match origin + path prefix (e.g. /pytest-plugin/) |
| 71 | + // Links without: match hostname only (e.g. https://libtmux.git-pull.com) |
| 72 | + const isActive = hasPath |
| 73 | + ? sameHost && loc.pathname.startsWith(url.pathname.replace(/\/+$/, "")) |
| 74 | + : sameHost; |
| 75 | + if (isActive && !link.classList.contains("active")) { |
| 76 | + const d = document.createElement('span'); |
| 77 | + d.textContent = link.textContent; |
| 78 | + d.classList.add("active"); |
| 79 | + link.parentNode.replaceChild(d, link); |
| 80 | + } |
| 81 | + }); |
68 | 82 | sidebar.classList.add('ready'); |
69 | 83 | })() |
70 | 84 | </script> |
0 commit comments