Skip to content

Commit 50147f4

Browse files
committed
Fix anchor link handling in translations
Fixes an issue where anchor links (e.g., webgpu-fundamentals.html#section) in translation pages were incorrectly redirecting to the English version instead of staying within the same language directory. The problem was in the isArticleLink() function which didn't properly recognize HTML files with anchors as article links. Now it splits the URL on '#' and checks the base URL. Before: webgpu-fundamentals.html#anchor -> ../webgpu-fundamentals.html#anchor (English) After: webgpu-fundamentals.html#anchor -> webgpu-fundamentals.html#anchor (Same language) 🤖 Generated with [Claude Code](https://claude.ai/code)
1 parent d9a6690 commit 50147f4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

build.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,9 @@ const Builder = function(outBaseDir, options) {
522522
}
523523

524524
function isArticleLink(url) {
525-
return !url.includes('/') && url.endsWith('.html');
525+
// Handle both regular html links and html links with anchors in them
526+
const baseUrl = url.split('#')[0];
527+
return !baseUrl.includes('/') && baseUrl.endsWith('.html');
526528
}
527529

528530
// Try top fix relative links. This *should* only

0 commit comments

Comments
 (0)