Conversation
|
@tobiaszrolla Pomysł powstał z twojej PR-ki więc jak przejdzie, możesz już zmienić nazwę podstrony jak będziesz chciał |
There was a problem hiding this comment.
Pull request overview
This PR updates the route generation logic to support human-friendly menu labels with spaces derived from page filenames, aligning menu display with the desired naming convention.
Changes:
- Added a
splitFirsthelper to split filenames only on the first underscore (prefix separator). - Transformed the route display name by replacing remaining underscores with spaces.
- Updated
routesentries to use the new spaced menu name.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return { | ||
| path: routePath, | ||
| name: cleanName, | ||
| name: menuName, |
There was a problem hiding this comment.
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.
| const prefix = hasPrefix ? fullFileName.split("_")[0] : null; | ||
| const cleanName = hasPrefix ? fullFileName.split("_")[1] : fullFileName; | ||
| const [prefix, cleanName] = splitFirst(fullFileName, "_"); | ||
| const menuName = cleanName.replaceAll("_", " "); |
There was a problem hiding this comment.
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.
| if (index === -1) { | ||
| return [null, str]; | ||
| } | ||
| return [str.slice(0, index), str.slice(index + 1)]; |
There was a problem hiding this comment.
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.
| return [str.slice(0, index), str.slice(index + 1)]; | |
| return [str.slice(0, index), str.slice(index + separator.length)]; |
|
Hej to nie do końca chodzi o same spacje tylko o to aby nazwa strony w adresie mogła różnić się od nazwy napisanej w menu. Nie wiem czy to rozwiązuje ten problem |
|
Dobra chyba źle zrozumiałam, pokombinuję jeszcze ale jak nie to się zrobi po ostatecznej wersji |
Opis
Prosta funkcja dodająca możliwość dawania spacji w nazwach wyświetlanych w menu. Będzie zmiana w dokumentacji nazewnictwa podstron.
Powiązane zgłoszenie (Issue)
#45
Motywacja i kontekst
Po przejrzeniu istniejących PR, zauważyłam że potrzebna jest zmiana nazewnictwa podstron, która umożliwiałaby dodawanie "spacji".
Jak zostało to przetestowane?
Została stworzona strona testowa
Zrzuty ekranu (jeśli dotyczy):
Rodzaje zmian
Lista kontrolna: