fix: paper theme search and relative link resolution#45
Conversation
Search component was missing from paper theme. Add it with hidden trigger button so only keyboard shortcut (Cmd/Ctrl+K) opens the dialog. Refactor Search props from className to classNames object for flexibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace remark-strip-md-extensions with remark-resolve-links that resolves relative links (./page.mdx, ../dir/page.md) to absolute routes based on the source file's location. Also strips index/readme suffixes to match route conventions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR refactors the link resolution system in the documentation pipeline, updates the Search component's prop structure from a flat ChangesLink Resolution Plugin System
Search Component & Layout Integration
Documentation Navigation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 43 minutes and 6 seconds.Comment |
Load MDX module in /api/page endpoint to include _readingTime in frontmatter response, matching SSR behavior in entry-server.tsx. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/chronicle/src/lib/remark-resolve-links.ts`:
- Around line 11-12: The code uses filePath.indexOf('/content/') to find the
content dir which returns the first match and can pick up an outer path; change
this to use filePath.lastIndexOf('/content/') so contentIdx points to the final
/content/ segment before computing the relative suffix (update the const
contentIdx assignment in remark-resolve-links.ts and keep the subsequent
contentIdx === -1 guard and any substring/relative logic unchanged).
- Around line 17-21: The link visitor currently only skips http(s), fragments
and root-relative URLs, allowing other schemes (mailto:, ftp:, tel:, etc.) to be
mangled by the path resolution; update the guard in the visit callback (the
function using visit and inspecting node.url) to detect and skip any URI scheme
before calling path.posix.join — e.g. add a check using a scheme regex (letters
then letters/digits/+-. then colon) against node.url and return early when it
matches so non-file schemes are left unchanged.
In `@packages/chronicle/src/themes/paper/Layout.tsx`:
- Line 86: The problem is duplicate mounting of Search causing two Cmd/Ctrl+K
handlers; remove the redundant Search render from ApiLayout.tsx so only the
theme Layout owns Search. Edit ApiLayout.tsx and delete the <Search ... />
invocation (the component instance that ApiLayout passes in children), leaving
Layout (in packages/chronicle/src/themes/paper/Layout.tsx and the default theme)
as the sole place rendering Search; verify there are no other direct Search
mounts in ApiLayout-related JSX and ensure ApiLayout now relies on Layout to
provide the keyboard-triggered Search.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6a326ccc-cc24-4fbf-bcf8-ff733940c041
📒 Files selected for processing (11)
examples/versioned/content/dev/api.mdxexamples/versioned/content/dev/index.mdxexamples/versioned/content/docs/guide.mdxexamples/versioned/content/docs/index.mdxpackages/chronicle/src/components/ui/search.tsxpackages/chronicle/src/lib/remark-resolve-links.tspackages/chronicle/src/lib/remark-strip-md-extensions.tspackages/chronicle/src/pages/ApiLayout.tsxpackages/chronicle/src/server/vite-config.tspackages/chronicle/src/themes/paper/Layout.module.csspackages/chronicle/src/themes/paper/Layout.tsx
💤 Files with no reviewable changes (1)
- packages/chronicle/src/lib/remark-strip-md-extensions.ts
- Use lastIndexOf for /content/ to avoid matching outer path directories - Guard all URI schemes (mailto:, tel:, ftp:, etc.) not just http(s) - Remove duplicate Search mount from ApiLayout — theme Layouts own search Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Searchcomponent props fromclassNametoclassNamesobjectremark-strip-md-extensionswithremark-resolve-links— resolves relative links (./page.mdx,../dir/page.md) in MDX content to absolute routes based on source file location. Strips.md/.mdxextensions and normalizesindex/readmesuffixesTest plan
../dev/api.mdx) resolve correctly./index.mdx→/docs)./guide.mdx#section→/docs/guide#section)🤖 Generated with Claude Code