Skip to content

feature/ ability to add spaces in menu#46

Open
OlciXs wants to merge 1 commit intodevfrom
feature/spacing-in-menu
Open

feature/ ability to add spaces in menu#46
OlciXs wants to merge 1 commit intodevfrom
feature/spacing-in-menu

Conversation

@OlciXs
Copy link
Copy Markdown
Collaborator

@OlciXs OlciXs commented Apr 16, 2026

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):

image

Rodzaje zmian

  • Naprawa błędu (zmiana niełamiąca kompatybilności, która naprawia problem)
  • Nowa funkcja (zmiana niełamiąca kompatybilności, która dodaje funkcjonalność)
  • Zmiana łamiąca kompatybilność (naprawa lub funkcja, która spowodowałaby zmianę istniejącej funkcjonalności)

Lista kontrolna:

  • Mój kod jest zgodny ze stylem kodu tego projektu.
  • Moja zmiana wymaga zmiany w dokumentacji.
  • Zaktualizowałem odpowiednio dokumentację.

@OlciXs
Copy link
Copy Markdown
Collaborator Author

OlciXs commented Apr 16, 2026

@tobiaszrolla Pomysł powstał z twojej PR-ki więc jak przejdzie, możesz już zmienić nazwę podstrony jak będziesz chciał

Copy link
Copy Markdown
Contributor

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

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 splitFirst helper to split filenames only on the first underscore (prefix separator).
  • Transformed the route display name by replacing remaining underscores with spaces.
  • Updated routes entries to use the new spaced menu name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/routes-config.ts
return {
path: routePath,
name: cleanName,
name: menuName,
Copy link

Copilot AI Apr 16, 2026

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.
Comment thread src/lib/routes-config.ts
const prefix = hasPrefix ? fullFileName.split("_")[0] : null;
const cleanName = hasPrefix ? fullFileName.split("_")[1] : fullFileName;
const [prefix, cleanName] = splitFirst(fullFileName, "_");
const menuName = cleanName.replaceAll("_", " ");
Copy link

Copilot AI Apr 16, 2026

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.
Comment thread src/lib/routes-config.ts
if (index === -1) {
return [null, str];
}
return [str.slice(0, index), str.slice(index + 1)];
Copy link

Copilot AI Apr 16, 2026

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.
@tobiaszrolla
Copy link
Copy Markdown
Collaborator

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

@OlciXs
Copy link
Copy Markdown
Collaborator Author

OlciXs commented Apr 17, 2026

Dobra chyba źle zrozumiałam, pokombinuję jeszcze ale jak nie to się zrobi po ostatecznej wersji

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.

3 participants