feat(guides): strip numeric ordering prefix from rendered titles#3465
feat(guides): strip numeric ordering prefix from rendered titles#3465PierreBrisorgueil merged 1 commit intomasterfrom
Conversation
Guide files can now be prefixed with a numeric ordering key (`00-welcome.md`, `01-api-access.md`, ...) to control sidebar order without the digits leaking into the rendered Scalar titles. Sorting now uses the raw filename basename so prefixes still drive order after the visible title is stripped. Refs #3463
|
Warning Rate limit exceeded
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 59 minutes and 2 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3465 +/- ##
==========================================
+ Coverage 85.82% 85.85% +0.02%
==========================================
Files 115 115
Lines 2914 2919 +5
Branches 807 808 +1
==========================================
+ Hits 2501 2506 +5
Misses 327 327
Partials 86 86 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Updates the markdown guides helper so numeric filename prefixes can control sidebar ordering without showing up in rendered Scalar guide titles.
Changes:
- Strip leading numeric ordering prefixes (
^\d+[-_]) intitleFromPathbefore title-casing (with fallback to avoid empty titles). - Sort loaded guides by raw filename basename (instead of rendered title) to preserve ordering driven by numeric prefixes.
- Add unit tests covering prefixed/unprefixed filenames, digits-only basenames, and prefix-based ordering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/helpers/guides.js |
Strips numeric prefixes from displayed titles and changes guide sort key to filename basename. |
modules/core/tests/core.unit.tests.js |
Adds unit tests validating prefix stripping, digits-only behavior, and filename-based ordering. |
| .sort((a, b) => { | ||
| const keyA = path.basename(String(a.path), path.extname(String(a.path))); | ||
| const keyB = path.basename(String(b.path), path.extname(String(b.path))); | ||
| return keyA.localeCompare(keyB); | ||
| }); |
There was a problem hiding this comment.
The sort key uses plain localeCompare, which compares lexicographically. With non-zero-padded numeric prefixes (e.g. 2-foo.md vs 10-bar.md), this will order 10-… before 2-…, defeating the “any digit count” ordering-prefix behavior described above. Consider using Intl.Collator / localeCompare with { numeric: true }, and optionally add a secondary tie-breaker (e.g. full path) when basenames match to keep ordering deterministic.
Summary
titleFromPathnow strips a leadingNN-orNN_prefix before title-casing, so projects can use numeric ordering prefixes (00-welcome.md,01-api-access.md) without the digits leaking into rendered Scalar titles.42.md) fall back to the raw basename so we never emit an empty title.loadGuidesnow sorts on the raw filename basename instead of the rendered title, so numeric prefixes still drive order even after the visible title is stripped.Closes #3463
Test plan
npm run lintnpm run test:unit -- --testPathPatterns='core.unit'(506 passed)guides.jscoverage: 100% statements / 100% functions / 100% lines / 90% branches