Skip to content

Commit 3590a9e

Browse files
authored
Fixing the html comments (#84)
comments shouldn't break the build. Signed-off-by: JJ Asghar <[email protected]>
1 parent 9588652 commit 3590a9e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

remote-content/remote-sources/repo-transforms.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ function applyBasicMdxFixes(content) {
2929

3030
return `:::${docusaurusType}\n${cleanContent}\n:::\n`;
3131
})
32+
// Fix HTML comments for MDX compatibility
33+
.replace(/<!--\s*/g, '{/* ')
34+
.replace(/\s*-->/g, ' */}')
3235
// Fix HTML tags for MDX compatibility
3336
.replace(/<br>/g, '<br />')
3437
.replace(/<br([^/>]*?)>/g, '<br$1 />')
@@ -60,6 +63,28 @@ function resolvePath(path, sourceDir, repoUrl, branch) {
6063
return `${repoUrl}/blob/${branch}/${rootPath}`;
6164
}
6265

66+
// Handle complex relative paths with ../ navigation
67+
if (cleanPath.includes('../')) {
68+
// Split the source directory and the relative path
69+
const sourceParts = sourceDir ? sourceDir.split('/') : [];
70+
const pathParts = cleanPath.split('/');
71+
72+
// Process each part of the path
73+
const resolvedParts = [...sourceParts];
74+
for (const part of pathParts) {
75+
if (part === '..') {
76+
// Go up one directory
77+
resolvedParts.pop();
78+
} else if (part !== '.' && part !== '') {
79+
// Add the directory/file part
80+
resolvedParts.push(part);
81+
}
82+
}
83+
84+
const resolvedPath = resolvedParts.join('/');
85+
return `${repoUrl}/blob/${branch}/${resolvedPath}`;
86+
}
87+
6388
// Handle regular relative paths - these are relative to the source file's directory
6489
const fullPath = sourceDir ? `${sourceDir}/${cleanPath}` : cleanPath;
6590
return `${repoUrl}/blob/${branch}/${fullPath}`;

0 commit comments

Comments
 (0)