Skip to content

Conversation

@SoonIter
Copy link
Member

@SoonIter SoonIter commented Jan 6, 2026

Description

This PR moves the routePathToMdPath utility function from the Overview theme component to the core runtime utilities (@rspress/core/runtime).

Changes

  • Moved: routePathToMdPath logic to packages/core/src/runtime/utils.ts and exported it via packages/core/src/runtime/index.ts.
  • Improved: The function now uses a more robust regex (/\.html(?=#|\?|$)/) to correctly handle URLs with hashes and query parameters when replacing extensions.
  • Refactored: Updated packages/core/src/theme/components/Overview/index.tsx to use the exposed utility and removed the local implementation.
  • Tests: Added unit tests in packages/core/src/runtime/utils.test.ts to ensure correct behavior across various URL formats.

This PR was written using Vibe Kanban

…function in `@rspress/core/runtime` by moving it to `packages/core/src/runtime/utils.ts`, updating the implementation with the requested logic, and exporting it. I also updated `packages/core/src/theme/components/Overview/index.tsx` to use the exposed function. Finally, I verified the changes by building the package and creating a unit test `packages/core/src/runtime/utils.test.ts` which covers various scenarios.

**Summary of changes:**
1.  **Modified `packages/core/src/runtime/utils.ts`**: Added `routePathToMdPath` with the improved logic `url.replace(/\.html(?=#|\?|$)/, '.md')` and exported it.
2.  **Modified `packages/core/src/runtime/index.ts`**: Exported `routePathToMdPath` from `utils`.
3.  **Modified `packages/core/src/theme/components/Overview/index.tsx`**: Removed local implementation and imported `routePathToMdPath` from `@rspress/core/runtime`. Removed unused imports (`normalizeHref`, `withBase`).
4.  **Created `packages/core/src/runtime/utils.test.ts`**: Added unit tests to verify the logic.

Verified with `pnpm build` in `packages/core` and `pnpm rstest run packages/core/src/runtime/utils.test.ts`.
…s with hashes and query parameters. The tests use `matchInlineSnapshot` and I've verified the snapshots are correctly generated and the logic holds up.

**Summary of changes:**
1.  Modified `packages/core/src/runtime/utils.test.ts` to include a comprehensive list of test cases (hash, query, combinations).
2.  Updated the test to use `toMatchInlineSnapshot`.
3.  Executed `npx rstest` to generate the correct snapshots.

The `routePathToMdPath` function is now well-tested and verified.
Copilot AI review requested due to automatic review settings January 6, 2026 10:10
@netlify
Copy link

netlify bot commented Jan 6, 2026

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit 97d2078
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/695cdf7ef4986800080fcb22
😎 Deploy Preview https://deploy-preview-2967--rspress-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@SoonIter SoonIter changed the title 将 routePathToMdPath 这个 util 函数在 @rspress/core/runtime 中暴露出来 (vibe-kanban) feat(core): expose routePathToMdPath utility in runtime (Vibe Kanban) Jan 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the routePathToMdPath utility function by moving it from the Overview component to the runtime utils module, making it available for reuse across the codebase. The refactoring also includes an improvement to the regex pattern for handling query strings and hash fragments.

Key Changes:

  • Moved routePathToMdPath function from Overview component to @rspress/core/runtime utils
  • Improved regex pattern from /\.html$/ to /\.html(?=#|\?|$)/ to correctly handle URLs with query strings and hash fragments
  • Added comprehensive test coverage with snapshot testing for various URL formats

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/theme/components/Overview/index.tsx Removed local routePathToMdPath implementation and imports for normalizeHref and withBase; now imports the function from runtime
packages/core/src/runtime/utils.ts Added routePathToMdPath function implementation with improved regex pattern and exported it
packages/core/src/runtime/utils.test.ts Added new test file with comprehensive test cases covering various URL formats including paths with hashes, query strings, and combinations
packages/core/src/runtime/index.ts Exported routePathToMdPath function to make it publicly available in the runtime API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Rsdoctor Bundle Diff Analysis

Found 3 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
node 9.5 MB 0
node_md 1.2 MB 0
web 15.3 MB 0

Generated by Rsdoctor GitHub Action

@SoonIter SoonIter requested a review from Timeless0911 January 6, 2026 10:13
@SoonIter SoonIter changed the title feat(core): expose routePathToMdPath utility in runtime (Vibe Kanban) chore(core): expose routePathToMdPath utility in runtime (Vibe Kanban) Jan 6, 2026
@Timeless0911 Timeless0911 changed the title chore(core): expose routePathToMdPath utility in runtime (Vibe Kanban) chore(core): expose routePathToMdPath utility in runtime Jan 6, 2026
@Timeless0911 Timeless0911 merged commit ecb6680 into main Jan 6, 2026
18 checks passed
@Timeless0911 Timeless0911 deleted the vk/aa4b-routepathtomdpat branch January 6, 2026 11:27
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.

3 participants