chore(core): expose routePathToMdPath utility in runtime#2967
Merged
Timeless0911 merged 2 commits intomainfrom Jan 6, 2026
Merged
chore(core): expose routePathToMdPath utility in runtime#2967Timeless0911 merged 2 commits intomainfrom
Timeless0911 merged 2 commits intomainfrom
Conversation
…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.
✅ Deploy Preview for rspress-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
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
routePathToMdPathfunction from Overview component to@rspress/core/runtimeutils - 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.
Contributor
Rsdoctor Bundle Diff AnalysisFound 3 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
Timeless0911
approved these changes
Jan 6, 2026
This was referenced Jan 6, 2026
feat(ssg-md): add SSG-MD support to OverviewGroup and FallbackHeading components (Vibe Kanban)
#2966
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR moves the
routePathToMdPathutility function from theOverviewtheme component to the core runtime utilities (@rspress/core/runtime).Changes
routePathToMdPathlogic topackages/core/src/runtime/utils.tsand exported it viapackages/core/src/runtime/index.ts./\.html(?=#|\?|$)/) to correctly handle URLs with hashes and query parameters when replacing extensions.packages/core/src/theme/components/Overview/index.tsxto use the exposed utility and removed the local implementation.packages/core/src/runtime/utils.test.tsto ensure correct behavior across various URL formats.This PR was written using Vibe Kanban