Skip to content

Conversation

@KyleAMathews
Copy link
Owner

Summary

  • Adds path normalization to the MarkdownLink component to handle the difference between GitHub's file-based paths and the website's route-based paths
  • Converts ./path style links to ../path to account for the website's URL structure where docs are at /library/version/docs/file (without trailing slash)
  • This allows documentation authors to use GitHub-compatible relative links that also work correctly on tanstack.com

Context

This fixes the issue described in TanStack/db#449 where relative links between documentation pages require different paths for GitHub vs the website.

The problem occurs because:

  • In GitHub: A link from docs/overview.md to docs/guides/live-queries.md uses ./guides/live-queries.md
  • On tanstack.com: The URL is /library/version/docs/overview (no trailing slash), so relative paths resolve differently and need ../guides/live-queries.md

Test plan

  • Test that existing documentation links still work correctly on the website
  • Verify that GitHub-style relative links (./path) now work on the website
  • Check that absolute paths and external links are unaffected

🤖 Generated with Claude Code

KyleAMathews and others added 7 commits August 5, 2025 21:07
Adds path normalization to MarkdownLink component to handle the difference
between GitHub's file-based paths and the website's route-based paths.
Links like ./guides/foo.md now work correctly on both platforms.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Extends the normalization to handle paths like "guides/foo.md" (without ./)
that should be treated as sibling directories. This ensures compatibility
with various markdown link styles used in documentation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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>
- Resolved merge conflict in db.$version.index.tsx by keeping upstream LibraryHero component
- Removed accidentally committed .claude folder

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Extracted path normalization logic to separate utility function
- Added comprehensive test suite with 33 test cases covering real examples from DB and Router docs
- Handles all patterns: ./, ../, bare paths, external links, hash fragments
- All tests pass, ensuring no regressions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants