Skip to content

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented Aug 26, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Overview navigation link matching to correctly highlight active items.
    • Corrected header anchor links in Overview to navigate reliably.
    • Improved route normalization for consistent link behavior (including index routes and trailing slashes).
  • Chores

    • Added release metadata documenting a patch update for the package.

Copilot AI review requested due to automatic review settings August 26, 2025 06:43
@changeset-bot
Copy link

changeset-bot bot commented Aug 26, 2025

🦋 Changeset detected

Latest commit: 6095425

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@alauda/doom Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Aug 26, 2025

Walkthrough

The patch removes runtime href normalization from Overview.tsx, linking directly to item.link, and shifts path normalization in _utils.ts to use normalizeHref from @rspress/shared. A changeset file documents a patch release for "@alauda/doom" with "fix: overview matching logic". No public API changes.

Changes

Cohort / File(s) Summary of edits
Release metadata
\.changeset/new-keys-mix.md
Added patch changeset for "@alauda/doom" noting "fix: overview matching logic"; no code changes.
Overview link rendering
src/runtime/components/Overview.tsx
Removed normalizeHref usage from runtime imports and JSX. Replaced href={normalizeHref(item.link)} with href={item.link} and header links to use ${item.link}#${header.id}. Minor comment cleanup; no API changes.
Sidebar utils normalization
src/runtime/components/_utils.ts
Now imports normalizeHref from @rspress/shared. Updated internal removeIndex to return normalizeHref(link, true) instead of manual /index trimming. Comparison logic for route matching delegates to shared normalizer; no API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant O as Overview.tsx
  participant S as Sidebar Utils (_utils.ts)
  participant R as @rspress/shared.normalizeHref

  rect rgba(230,240,255,0.5)
  note over O: Rendering links
  U->>O: View overview
  O->>O: Build link hrefs
  note over O: New: use item.link directly
  end

  rect rgba(240,255,240,0.5)
  note over S: Route matching
  O->>S: findItemByRoutePath(routePath)
  S->>R: normalizeHref(link, true)
  R-->>S: normalizedLink
  S-->>O: matched item
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

Suggested labels

bug

Poem

A bunny hopped through links so bright,
Snipped the extra slashes tight,
Overview paths now clear and clean,
Shared norms guide what routes all mean,
Patch-release carrots, crisp and small—
One hop closer, no trips at all. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/overview

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Signed-off-by: JounQin <admin@1stg.me>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 26, 2025

Open in StackBlitz

yarn add https://pkg.pr.new/@alauda/doom@158.tgz

commit: 6095425

Copy link

@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: 0

🧹 Nitpick comments (4)
.changeset/new-keys-mix.md (1)

5-5: Clarify the release note for future readers.

Adding a one-liner about what “overview matching logic” specifically fixes will help consumers scanning the changelog.

 fix: overview matching logic
+  
+ - Centralize path normalization in utils via `@rspress/shared.normalizeHref` and remove redundant per-link normalization in `Overview`. Fixes mismatches between `/foo`, `/foo/`, and `/foo/index` during overview grouping.
src/runtime/components/_utils.ts (2)

8-10: Minor: rename helper to reflect behavior.

removeIndex now performs full normalization (not just trimming /index). Consider renaming to normalizePath (or similar) to better mirror semantics. No functional change required.


64-69: Review remaining manual “/index” logic
The grep results reveal additional call sites that still rely on manual “/index” or regex-based trimming rather than using removeIndex/normalizeHref. To ensure consistent URL normalization across the codebase, please review and consider refactoring these occurrences:

• src/theme.tsx (around line 40):
if (urlPath.endsWith('/index')) { … }

• src/cli/export.ts (around line 185):
…foundSidebarItems.find(it => it.link?.endsWith('/index'))…

You can replace these with calls to removeIndex(...) (or its underlying normalizeHref) to unify behavior and avoid edge cases with trailing slashes.

src/runtime/components/Overview.tsx (1)

241-241: Consider encoding header IDs when building hash links.

If any header IDs contain characters needing encoding, encodeURIComponent(header.id) would be safer. Rspress usually slugifies IDs, so this is a precautionary hardening.

- href={`${item.link}#${header.id}`}
+ href={`${item.link}#${encodeURIComponent(header.id)}`}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 01e8bf8 and 6095425.

📒 Files selected for processing (3)
  • .changeset/new-keys-mix.md (1 hunks)
  • src/runtime/components/Overview.tsx (3 hunks)
  • src/runtime/components/_utils.ts (1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/new-keys-mix.md

[grammar] ~5-~5: There might be a mistake here.
Context: ... patch --- fix: overview matching logic

(QB_NEW_EN)

🔇 Additional comments (4)
.changeset/new-keys-mix.md (1)

1-3: LGTM: patch bump is correct for a bug fix.

Version scope matches the change impact (internal correctness, no API surface change).

src/runtime/components/_utils.ts (1)

6-6: Good move: reuse normalizeHref from the shared package.

This consolidates normalization logic in one well-tested utility, reducing drift between components.

src/runtime/components/Overview.tsx (2)

6-6: Import cleanup is appropriate.

Dropping the local normalize step aligns with centralizing normalization in utils and avoids redundant work at render time.


227-227: Confirm Link’s base‐path and normalized‐route handling

I verified that in Overview.tsx (lines ~227) we pass href={item.link} directly, and Link is imported from @rspress/core/theme rather than using our local normalizeHref utility. Because we can’t inspect the theme’s Link implementation here, please double-check that:

  • Link automatically applies the site’s base path (e.g. /docs/) when rendering internal routes
  • It does not re-normalize or duplicate already-normalized, site-relative paths

This will ensure no double or missing base segments on sites served from a non-root base.

@JounQin JounQin merged commit 14f1b72 into main Aug 26, 2025
16 checks passed
@JounQin JounQin deleted the fix/overview branch August 26, 2025 06:53
github-actions bot pushed a commit that referenced this pull request Aug 26, 2025
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