Skip to content

Commit 77fb093

Browse files
KyleAMathewsclaude
andcommitted
fix: handle bare filename paths in markdown links
Extends normalization to handle all relative path formats: - "./foo.md" (explicit same directory) -> "../foo" - "foo.md" (bare filename, same directory) -> "../foo" - "./guides/foo.md" (explicit subdirectory) -> "../guides/foo" - "guides/foo.md" (bare subdirectory) -> "../guides/foo" This ensures all GitHub-compatible relative link formats work correctly on the website's routing structure. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c833958 commit 77fb093

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/components/MarkdownLink.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ export function MarkdownLink({
2323
if (to?.startsWith('./')) {
2424
// Convert ./path to ../path to account for the fact that we're at /docs/file not /docs/file/
2525
to = '../' + to.slice(2)
26-
} else if (to && !to.startsWith('/') && !to.startsWith('../') && to.includes('/')) {
27-
// Handle bare relative paths like "guides/foo" that should be treated as "../guides/foo"
28-
// This handles cases where markdown has "subfolder/file.md" instead of "./subfolder/file.md"
26+
} else if (to && !to.startsWith('/') && !to.startsWith('../')) {
27+
// Handle bare relative paths like "foo" or "guides/foo"
28+
// These should be treated as siblings, so prepend ../
29+
// This handles:
30+
// - "foo.md" (same directory) -> "../foo"
31+
// - "guides/foo.md" (subdirectory) -> "../guides/foo"
2932
to = '../' + to
3033
}
3134

0 commit comments

Comments
 (0)