Skip to content

Fix: apply root-level meta.jsonc order config#303

Merged
NullVoxPopuli merged 1 commit into
universal-ember:mainfrom
rmoodyab:fix-root-meta-jsonc-order
May 27, 2026
Merged

Fix: apply root-level meta.jsonc order config#303
NullVoxPopuli merged 1 commit into
universal-ember:mainfrom
rmoodyab:fix-root-meta-jsonc-order

Conversation

@rmoodyab
Copy link
Copy Markdown
Contributor

Summary

Root-level meta.jsonc order is silently ignored — sort falls back to whatever betterSort produces (effectively alphabetical via localeCompare, often unhelpful). Nested meta.jsonc files work fine; only the root case is broken.

Reproduction

In any group, place a meta.jsonc at the group root:

// docs/meta.jsonc
{ "order": ["getting-started", "ui-schema", "data-schema"] }

With folders getting-started/, ui-schema/, data-schema/ each containing an index.md. Expected: clicking the group lands on getting-started. Actual: lands on whatever sorts first alphabetically (in my repro, ui-schema/overview.md).

Root cause

In src/build/plugins/markdown-pages/sort.js, sortTree matches a config to a folder via:

const subPath = `${[...parents, tree.path].join('/')}`.replace(/^root\//, '');
const config = configs.find((c) => findPathForJsonc(c.path) === subPath)?.config;

function findPathForJsonc(path) {
  return path.replace(/\/meta\.jsonc?$/, '');
}

For the root tree, parents=[] and tree.path='root', so the joined string is just 'root' — no trailing slash to strip, subPath stays 'root'. Meanwhile the config path at the root is 'meta.jsonc' (no leading slash), and findPathForJsonc('meta.jsonc') returns 'meta.jsonc' (no leading slash to strip). They never match.

For nested folders both regexes naturally hit their slash (e.g. 'root/ui-schema''ui-schema', 'ui-schema/meta.jsonc''ui-schema'), so nested configs work.

Fix

Make the slash optional in both regexes (two ? characters):

- return path.replace(/\/meta\.jsonc?$/, '');
+ return path.replace(/\/?meta\.jsonc?$/, '');
- ...replace(/^root\//, '');
+ ...replace(/^root\/?/, '');

Now findPathForJsonc('meta.jsonc') returns '', subPath for the root tree becomes '', and they match.

Tested

Verified locally against my consumer (kolay@5.1.4) — the patched version correctly applies root-level order. Without the patch, the sidebar shows alphabetical order; with it, the configured order is honored.

No test in this PR — happy to add one if you point me at the right test-app to wire it through (test-apps/markdown-only looked closest but I didn't want to guess the convention).

The findPathForJsonc and subPath helpers both required a leading/trailing
slash that the root case doesn't have, so root-level meta.jsonc was never
matched and the configured order silently fell back to alphabetical sort.

Making the slashes optional fixes root-level config matching without
changing behavior for nested configs.

Reproducible by giving any group a root meta.jsonc and observing that
clicking the group's nav landed on an alphabetically-first page instead
of the order's first item.
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@rmoodyab is attempting to deploy a commit to the universal-ember Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
kolay-docs-app Ready Ready Preview, Comment May 27, 2026 6:57pm

@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label May 27, 2026
@NullVoxPopuli NullVoxPopuli merged commit b0b9033 into universal-ember:main May 27, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants