Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/lib/routes-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@ const pages = import.meta.glob<{ default: React.ComponentType }>(
"../pages/*.tsx",
);

const splitFirst = (str: string, separator: string): [string | null, string] => {
const index = str.indexOf(separator);
if (index === -1) {
return [null, str];
}
return [str.slice(0, index), str.slice(index + 1)];

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

splitFirst takes a generic separator: string, but slices using index + 1. If separator ever becomes longer than 1 character this will produce incorrect results; using index + separator.length (or constraining separator to a single character) would make the helper consistent with its signature.

Suggested change
return [str.slice(0, index), str.slice(index + 1)];
return [str.slice(0, index), str.slice(index + separator.length)];

Copilot uses AI. Check for mistakes.
};


export const routes = Object.keys(pages)
.filter((path) => !path.includes("_components"))
.map((path) => {
const fullFileName = path.split("/").pop()?.replace(".tsx", "") || "";
const hasPrefix = fullFileName.includes("_");
const prefix = hasPrefix ? fullFileName.split("_")[0] : null;
const cleanName = hasPrefix ? fullFileName.split("_")[1] : fullFileName;
const [prefix, cleanName] = splitFirst(fullFileName, "_");
const menuName = cleanName.replaceAll("_", " ");

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

PR description mentions an upcoming documentation update for page/menu naming, but this PR only changes runtime routing/menu naming logic. Either include the doc change in this PR or adjust the PR description/checklist so it matches the actual scope.

Copilot uses AI. Check for mistakes.

const routePath =
cleanName.toLowerCase() === "app" ? "/" : `/${cleanName.toLowerCase()}`;

return {
path: routePath,
name: cleanName,
name: menuName,

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

Changing name from the raw cleanName to a display label with spaces can break existing consumers that treat route.name as a stable identifier (e.g. lookups like exerciseIcons[exercise.name.toLowerCase()] in src/pages/_components/ExercisesSection.tsx). Consider keeping name as the original cleanName (identifier) and adding a separate field (e.g. label/menuName) for UI display, or update all identifier-based lookups to normalize the spaced label back to the expected key.

Copilot uses AI. Check for mistakes.
prefix: prefix,
component: React.lazy(() => pages[path]()),
};
Expand Down