Skip to content

[TASK] Refactor Breadcrumb Logic for Scalability #33781

@adrianjm-dotCMS

Description

@adrianjm-dotCMS

Description

The current logic for generating breadcrumbs for "special cases" (routes that don't map 1:1 with a menu item, like /templates/edit/:id or /content?filter=) is handled with a growing if/else block.

This approach is difficult to maintain and is not scalable. As we add more special routes, this conditional logic will become complex and error-prone.

Objective: Refactor this implementation to use a more scalable "Strategy Map" pattern (e.g., a Map or an object literal). The goal is to map a URL pattern (or a function that tests the URL) to a specific handler function responsible for building the breadcrumbs for that case.

This will allow us to register new special cases cleanly without modifying the core logic, simply by adding a new entry to the map.

Acceptance Criteria

  • AC1: The existing if/else block for handling special breadcrumb cases must be removed.

  • AC2: A map-like structure (e.g., Map, Object) must be implemented to register handler functions for special cases.

  • AC3: The existing cases (/templates/edit/:id and /content?filter=) must be migrated to use this new pattern.

  • AC4: The breadcrumb functionality must remain identical to the user. This is a refactor and should not introduce any behavioral changes.

  • AC5: The new structure must make it easy to add future special cases simply by registering a new handler, without touching the main processing logic.

Priority

None

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions