summaryrefslogtreecommitdiffstats
path: root/head.html
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-05-08 13:06:35 +0200
committerDanilo M. <danix@danix.xyz>2026-05-08 13:06:35 +0200
commit63fbcc4b54184f0e33ab1ae2e898e7456e5fa8de (patch)
tree8a807f908af4a75d5a5657640fa7b095c6d4dec3 /head.html
parent3a65681a75ba7d8534e0b9e5af62b5d3959ebc62 (diff)
downloadcgit-theme-danix-master.tar.gz
cgit-theme-danix-master.zip
fix(about): rewrite relative img src to cgit plain/ endpointHEADmaster
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>
Diffstat (limited to 'head.html')
-rw-r--r--head.html15
1 files changed, 15 insertions, 0 deletions
diff --git a/head.html b/head.html
index 96f3daf..68bda81 100644
--- a/head.html
+++ b/head.html
@@ -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>