Skip to content

fix: paper theme search and relative link resolution#45

Merged
rsbh merged 4 commits intomainfrom
fix_paper_theme_search
May 4, 2026
Merged

fix: paper theme search and relative link resolution#45
rsbh merged 4 commits intomainfrom
fix_paper_theme_search

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented May 4, 2026

Summary

  • Enable search in paper theme — Cmd/Ctrl+K opens search dialog, no visible trigger button. Refactor Search component props from className to classNames object
  • Replace remark-strip-md-extensions with remark-resolve-links — resolves relative links (./page.mdx, ../dir/page.md) in MDX content to absolute routes based on source file location. Strips .md/.mdx extensions and normalizes index/readme suffixes

Test plan

  • Paper theme: press Cmd/Ctrl+K — search dialog opens, no visible search button
  • Default theme: search button still visible and functional
  • Relative links in MDX content resolve to correct absolute routes
  • Cross-content-dir links (../dev/api.mdx) resolve correctly
  • Index/readme links resolve to parent route (./index.mdx/docs)
  • Hash links preserved (./guide.mdx#section/docs/guide#section)
  • API layout search still works

🤖 Generated with Claude Code

rsbh and others added 2 commits May 4, 2026 12:23
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>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chronicle Ready Ready Preview, Comment May 4, 2026 10:30am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@rsbh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 6 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2ae9d706-2739-428d-9215-cd7afd22091d

📥 Commits

Reviewing files that changed from the base of the PR and between 17bbd4f and 62a7a7c.

📒 Files selected for processing (3)
  • packages/chronicle/src/lib/remark-resolve-links.ts
  • packages/chronicle/src/pages/ApiLayout.tsx
  • packages/chronicle/src/server/api/page.ts
📝 Walkthrough

Walkthrough

This PR refactors the link resolution system in the documentation pipeline, updates the Search component's prop structure from a flat className to a nested classNames interface, integrates Search into the main layout with conditional rendering, and adds cross-navigation links within versioned documentation files.

Changes

Link Resolution Plugin System

Layer / File(s) Summary
Plugin Implementation
packages/chronicle/src/lib/remark-resolve-links.ts
New Unified remark plugin that rewrites relative Markdown links to absolute paths, stripping .md/.mdx extensions and normalizing paths from the content directory.
Plugin Removal
packages/chronicle/src/lib/remark-strip-md-extensions.ts
Deleted the previous extension-stripping plugin implementation.
Build Configuration
packages/chronicle/src/server/vite-config.ts
Vite MDX plugin configuration updated to import and use remarkResolveLinks instead of remarkStripMdExtensions.

Search Component & Layout Integration

Layer / File(s) Summary
Component API
packages/chronicle/src/components/ui/search.tsx
SearchProps refactored from className?: string to nested classNames?: { trigger?: string } with corresponding parameter updates.
Styling Foundation
packages/chronicle/src/themes/paper/Layout.module.css
New .hiddenTrigger CSS class added with display: none;.
Layout Integration
packages/chronicle/src/themes/paper/Layout.tsx
Conditionally renders Search component when config.search?.enabled is true, using the new classNames prop structure.
Consumer Update
packages/chronicle/src/pages/ApiLayout.tsx
Search usage updated to pass classNames={{ trigger: styles.hiddenSearch }} instead of className.

Documentation Navigation

Layer / File(s) Summary
Cross-Links
examples/versioned/content/dev/api.mdx, examples/versioned/content/dev/index.mdx, examples/versioned/content/docs/guide.mdx, examples/versioned/content/docs/index.mdx
Navigation bullet lists added to link between dev and docs sections, enabling cross-document browsing within versioned documentation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Suggested reviewers

  • rohilsurana
  • rohanchkrabrty
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures both main changes: enabling search in the paper theme and replacing the link resolution plugin for relative links.
Description check ✅ Passed The description clearly explains the two major changes (search refactoring and link resolution plugin replacement) and includes a detailed test plan matching the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix_paper_theme_search

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 43 minutes and 6 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

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>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9c0a7f9 and 17bbd4f.

📒 Files selected for processing (11)
  • examples/versioned/content/dev/api.mdx
  • examples/versioned/content/dev/index.mdx
  • examples/versioned/content/docs/guide.mdx
  • examples/versioned/content/docs/index.mdx
  • packages/chronicle/src/components/ui/search.tsx
  • packages/chronicle/src/lib/remark-resolve-links.ts
  • packages/chronicle/src/lib/remark-strip-md-extensions.ts
  • packages/chronicle/src/pages/ApiLayout.tsx
  • packages/chronicle/src/server/vite-config.ts
  • packages/chronicle/src/themes/paper/Layout.module.css
  • packages/chronicle/src/themes/paper/Layout.tsx
💤 Files with no reviewable changes (1)
  • packages/chronicle/src/lib/remark-strip-md-extensions.ts

Comment thread packages/chronicle/src/lib/remark-resolve-links.ts Outdated
Comment thread packages/chronicle/src/lib/remark-resolve-links.ts
Comment thread packages/chronicle/src/themes/paper/Layout.tsx
- 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>
@rsbh rsbh merged commit 5da4bf3 into main May 4, 2026
4 checks passed
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