Skip to content

Commit d24980a

Browse files
sriakula1claude
andcommitted
🔗 Fix anchor links to point to GitHub repository
Convert internal anchor links in rendered README content to GitHub repository URLs so table of contents and section links actually work on the GitHub Pages site. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fd69779 commit d24980a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docs/script.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,21 @@ function postProcessReadmeContent(container) {
117117
});
118118
});
119119

120-
// Add click tracking for anchor links
120+
// Convert anchor links to GitHub repository links
121121
const anchorLinks = container.querySelectorAll('a[href^="#"]');
122122
anchorLinks.forEach(link => {
123+
const anchor = link.getAttribute('href');
124+
// Convert local anchor links to GitHub repository links
125+
const githubUrl = `https://github.com/xpaysh/awesome-x402?tab=readme-ov-file${anchor}`;
126+
link.setAttribute('href', githubUrl);
127+
link.setAttribute('target', '_blank');
128+
link.setAttribute('rel', 'noopener noreferrer');
129+
123130
link.addEventListener('click', (e) => {
124131
gtmPush({
125132
'event': 'anchor_link_click',
126-
'anchor_target': link.href.split('#')[1]
133+
'anchor_target': anchor.split('#')[1],
134+
'github_url': githubUrl
127135
});
128136
});
129137
});

0 commit comments

Comments
 (0)