Skip to content

fix: homepage rendering and client-side navigation issues#32

Merged
rsbh merged 4 commits into
mainfrom
fix_homepage_render
Apr 14, 2026
Merged

fix: homepage rendering and client-side navigation issues#32
rsbh merged 4 commits into
mainfrom
fix_homepage_render

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented Apr 14, 2026

Summary

  • Fix 404 on /api/page/ during client-side navigation to homepage by adding index route handler that re-exports the catch-all handler
  • Sync breadcrumbs with content during navigation by using page.slug from context instead of route slug
  • Use ApsaraLink for all MDX links (local + external) for consistent styling

Test plan

  • Click sidebar/navbar links to navigate to homepage — no 404
  • Rename index.mdx to README.md — homepage still resolves
  • Breadcrumbs and content update together on navigation (no stale breadcrumbs)
  • Local and external links in MDX content have consistent Apsara styling
  • Local links still use client-side navigation (no full page reload)

🤖 Generated with Claude Code

rsbh and others added 3 commits April 14, 2026 12:15
Nitro's [...slug] catch-all doesn't match empty path /api/page/.
Re-export the catch-all handler as index.ts so the homepage API
route works for both index.md and README.md variants.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use page.slug from context instead of route slug so breadcrumbs
and content update together when the fetch completes, avoiding
flicker.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Local links now use ApsaraLink with onClick + useNavigate instead
of RouterLink, ensuring consistent styling across internal and
external links.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 32 minutes and 39 seconds.

⌛ 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: eafc06ea-c675-4c1e-b118-de6be0ec7af5

📥 Commits

Reviewing files that changed from the base of the PR and between c01499b and 27531cb.

📒 Files selected for processing (1)
  • packages/chronicle/src/components/mdx/link.tsx
📝 Walkthrough

Walkthrough

The Link component is refactored to use programmatic navigation via useNavigate from react-router, replacing the previous RouterLink implementation. The DocsPage component now uses page.slug instead of the route parameter slug. The page API module adds a re-export of the [...slug] handler through its index file.

Changes

Cohort / File(s) Summary
Navigation Component Updates
packages/chronicle/src/components/mdx/link.tsx
Refactored Link component to use useNavigate hook with an onClick handler for programmatic navigation instead of RouterLink component. Updated imports and adjusted branch order for anchor/external link handling.
Page Component Updates
packages/chronicle/src/pages/DocsPage.tsx
Changed slug prop passed to themed Page component from route parameter slug to page.slug.
API Module Exports
packages/chronicle/src/server/api/page/index.ts
Added default export re-export from ./[...slug] module to make the handler available through the index entrypoint.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main changes: fixing homepage rendering and client-side navigation issues, which aligns with the three key fixes in the changeset.
Description check ✅ Passed The description is directly related to the changeset, providing clear context about the fixes (404 resolution, breadcrumb synchronization, consistent link styling) and including a test plan aligned with the changes.

✏️ 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_homepage_render

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

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

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: 1

🧹 Nitpick comments (1)
packages/chronicle/src/pages/DocsPage.tsx (1)

33-33: Keep jsonLd.url consistent with the same slug source.

Good change on Line 33. To avoid transient metadata/content mismatch during navigation, compute pageUrl from page.slug as well (currently Line 15 uses route slug).

Suggested patch
-  const pageUrl = config.url ? `${config.url}/${slug.join('/')}` : undefined;
+  const pageUrl = config.url ? `${config.url}/${page.slug.join('/')}` : undefined;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/chronicle/src/pages/DocsPage.tsx` at line 33, The jsonLd.url should
be built from the same slug source as the page metadata to avoid mismatches:
change the code that computes pageUrl (currently using the route slug) to use
page.slug instead, and update any uses of jsonLd.url to reference that pageUrl;
look for variables named pageUrl, jsonLd, and page.slug in DocsPage (and any
nearby slug/route variables) and ensure pageUrl is derived from page.slug before
assigning jsonLd.url.
🤖 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/components/mdx/link.tsx`:
- Around line 38-45: The current onClick handler unconditionally calls
preventDefault and overrides caller handlers; update the onClick for ApsaraLink
to (1) early-return to preserve native semantics when the event is already
defaultPrevented, when e.metaKey/e.ctrlKey/e.shiftKey or e.altKey are true, or
when e.button !== 0 (non-left/middle clicks), (2) call props.onClick(event) if
present before deciding to preventDefault/navigate and respect its
defaultPrevented result, (3) only call event.preventDefault() and navigate(href)
for plain left-clicks without modifiers, and (4) change the JSX to spread
{...props} before specifying onClick (so our handler isn't accidentally
overridden) while still forwarding children via ApsaraLink.

---

Nitpick comments:
In `@packages/chronicle/src/pages/DocsPage.tsx`:
- Line 33: The jsonLd.url should be built from the same slug source as the page
metadata to avoid mismatches: change the code that computes pageUrl (currently
using the route slug) to use page.slug instead, and update any uses of
jsonLd.url to reference that pageUrl; look for variables named pageUrl, jsonLd,
and page.slug in DocsPage (and any nearby slug/route variables) and ensure
pageUrl is derived from page.slug before assigning jsonLd.url.
🪄 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: ba184881-8fce-4770-8c0a-09e7e77f33e5

📥 Commits

Reviewing files that changed from the base of the PR and between 50401fc and c01499b.

📒 Files selected for processing (3)
  • packages/chronicle/src/components/mdx/link.tsx
  • packages/chronicle/src/pages/DocsPage.tsx
  • packages/chronicle/src/server/api/page/index.ts

Comment thread packages/chronicle/src/components/mdx/link.tsx
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rsbh rsbh merged commit d3e2647 into main Apr 14, 2026
1 check 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