Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to show breadcrumbs for empty path routes #200

Closed
wants to merge 1 commit into from

Conversation

lukasmatta
Copy link
Contributor

@lukasmatta lukasmatta commented May 29, 2024

Currently, if there is an empty path child route (it can be that the route is using matcher instead of path), its breadcrumb is not rendered as a separate breadcrumb, but instead, it replaces parent route breadcrumb.

This PR introduces breadcrumb option force, when set to true, it forces breadcrumb of an empty path route to be rendered as a separate one.

To illustrate on an example:

export const ROUTES: Route[] = [
  {
    path: 'sample',
    component: SampleComponent,
    data: {
      breadcrumb: {
        label: 'Sample Component',
      },
    },
    children: [
      {
        matcher: (url) => (url.length === 1 && url[0].path === 'hello-world' ? { consumed: url } : null),
        component: HelloWorldComponent,
        data: {
          breadcrumb: {
            label: 'Hello World',
            force: true, // note the force option
          },
        },
      },
    ],
  },
];

Currently, the breadcrumbs for this route structure when visiting /sample/hello-world route looks like this: Sample Component. With this PR it will look like this: Sample Component / Hello World.

Resolves #148 and #199 in a non-breaking way.

When empty path child route has force option set to true,
it will be shown as a separate breadcrumb instead of replacing
parent's breadcrumb data.
@lukasmatta lukasmatta requested a review from udayvunnam as a code owner May 29, 2024 09:24
Copy link

vercel bot commented May 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
xng-breadcrumb ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 9:24am

Copy link

nx-cloud bot commented May 29, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit a712f95. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 3 targets

Sent with 💌 from NxCloud.

@lukasmatta lukasmatta changed the title Add option to show breadcrumbs for empty path routes feat: add option to show breadcrumbs for empty path routes May 29, 2024
Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to setup breadcrumb for certain route paths
1 participant