diff options
| author | Danilo M. <danix@danix.xyz> | 2026-05-08 13:06:35 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-05-08 13:06:35 +0200 |
| commit | 63fbcc4b54184f0e33ab1ae2e898e7456e5fa8de (patch) | |
| tree | 8a807f908af4a75d5a5657640fa7b095c6d4dec3 | |
| parent | 3a65681a75ba7d8534e0b9e5af62b5d3959ebc62 (diff) | |
| download | cgit-theme-danix-63fbcc4b54184f0e33ab1ae2e898e7456e5fa8de.tar.gz cgit-theme-danix-63fbcc4b54184f0e33ab1ae2e898e7456e5fa8de.zip | |
README images with relative paths resolve incorrectly on /about/ pages.
JS now rewrites them to /REPO/plain/PATH?h=BRANCH on DOMContentLoaded.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | head.html | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -15,5 +15,20 @@ document.addEventListener('DOMContentLoaded', function() { node.textContent = node.textContent.replace(' : ', '/'); } }); + + // Rewrite relative img src in README/about pages to cgit plain/ endpoint + if (/\/about\//.test(window.location.pathname)) { + var m = window.location.pathname.match(/^\/([^/]+)\/about\//); + if (m) { + var repo = m[1]; + var branch = (new URLSearchParams(window.location.search)).get('h') || 'main'; + document.querySelectorAll('div#summary img').forEach(function(img) { + var src = img.getAttribute('src'); + if (src && !/^https?:\/\//.test(src) && !/^\//.test(src)) { + img.src = '/' + repo + '/plain/' + src + '?h=' + branch; + } + }); + } + } }); </script> |
