Skip to content

feat(guides): strip numeric ordering prefix from rendered titles#3465

Merged
PierreBrisorgueil merged 1 commit intomasterfrom
feat/guides-strip-numeric-prefix
Apr 13, 2026
Merged

feat(guides): strip numeric ordering prefix from rendered titles#3465
PierreBrisorgueil merged 1 commit intomasterfrom
feat/guides-strip-numeric-prefix

Conversation

@PierreBrisorgueil
Copy link
Copy Markdown
Contributor

Summary

  • titleFromPath now strips a leading NN- or NN_ 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.
  • Digits-only filenames (42.md) fall back to the raw basename so we never emit an empty title.
  • loadGuides now 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 lint
  • npm run test:unit -- --testPathPatterns='core.unit' (506 passed)
  • guides.js coverage: 100% statements / 100% functions / 100% lines / 90% branches
  • New unit tests cover prefixed filenames, non-prefixed filenames, digits-only fallback, and numeric-prefix sort order

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
Copilot AI review requested due to automatic review settings April 13, 2026 18:10
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

Warning

Rate limit exceeded

@PierreBrisorgueil has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 2 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 59 minutes and 2 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: ASSERTIVE

Plan: Pro

Run ID: 3578179a-68da-43c4-9794-ec7139a32c40

📥 Commits

Reviewing files that changed from the base of the PR and between fcfa5b1 and 4ea0e5d.

📒 Files selected for processing (2)
  • lib/helpers/guides.js
  • modules/core/tests/core.unit.tests.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/guides-strip-numeric-prefix

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.85%. Comparing base (fcfa5b1) to head (4ea0e5d).
⚠️ Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

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

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+[-_]) in titleFromPath before 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.

Comment on lines +79 to +83
.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);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@PierreBrisorgueil PierreBrisorgueil merged commit 9ebb211 into master Apr 13, 2026
9 checks passed
@PierreBrisorgueil PierreBrisorgueil deleted the feat/guides-strip-numeric-prefix branch April 13, 2026 18:38
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.

feat(guides): strip numeric ordering prefix from rendered titles

2 participants