RoverCore.BreadCrumbs 1.0.3

dotnet add package RoverCore.BreadCrumbs --version 1.0.3
NuGet\Install-Package RoverCore.BreadCrumbs -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RoverCore.BreadCrumbs" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RoverCore.BreadCrumbs --version 1.0.3
#r "nuget: RoverCore.BreadCrumbs, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RoverCore.BreadCrumbs as a Cake Addin
#addin nuget:?package=RoverCore.BreadCrumbs&version=1.0.3

// Install RoverCore.BreadCrumbs as a Cake Tool
#tool nuget:?package=RoverCore.BreadCrumbs&version=1.0.3

RoverCore BreadCrumbs

This small library provides a service that makes it easy to add and customize breadcrumbs. The idea is to allow you to create a simple list of breadcrumbs using this service that you can render using a component. What's nice about this approach is that you can add the entire breadcrumb trail in an MVC action method and include the component in your shared _layout.cshtml page.

Example

Usage

Install

Install the package using NuGet
Install-Package RoverCore.BreadCrumbs

Initialize

After you have setup your breadcrumbs you must add the breadcrumbs service:

services.AddScoped<IBreadCrumbService, BreadCrumbService>();

Update your Layout

Update your Shared/_Layout.cshtml and call the BreadCrumbs ViewComponent wherever you want the breadcrumbs to appear.


@(await Component.InvokeAsync<BreadCrumbsViewComponent>())

Adding breadcrumbs

Include the IBreadCrumbService dependency service in your controller.

public class DashboardController : Controller
{
  private readonly IBreadCrumbService _breadcrumbs;
  
  public HomeController (IBreadCrumbService breadcrumbs)
  {
    _breadcrumbs = breadcrumbs;
  }
  
  public IActionResult Index()
  {
    _breadcrumbs.StartAtAction("Dashboard", "Index", "Dashboard", new { Area = "Admin"})
        .Then("Home");
            
    return View();
  }

...
}

Building your trail

There are a number of helpful extension methods that help you build your full breadcrumb trail fluently. See the following:

    public static IBreadCrumbService StartAt(this IBreadCrumbService breadCrumbService, string title)
    
    public static IBreadCrumbService StartAt(this IBreadCrumbService breadCrumbService, string title, string url)
    
    public static IBreadCrumbService StartAtAction(this IBreadCrumbService breadCrumbService, string title, string? action = default,
        string? controller = default,
        object? values = default,
        PathString? pathBase = default,
        FragmentString fragment = default,
        LinkOptions? options = default)

    public static IBreadCrumbService StartAtPage(this IBreadCrumbService breadCrumbService, string title,
        string? page = default,
        string? handler = default,
        object? values = default,
        PathString? pathBase = default,
        FragmentString fragment = default,
        LinkOptions? options = default)

    public static IBreadCrumbService Then(this IBreadCrumbService breadCrumbService, string title)

    public static IBreadCrumbService Then(this IBreadCrumbService breadCrumbService, string title, string url)

    public static IBreadCrumbService ThenAction(this IBreadCrumbService breadCrumbService, string title,
        string? action = default,
        string? controller = default,
        object? values = default,
        PathString? pathBase = default,
        FragmentString fragment = default,
        LinkOptions? options = default)

    public static IBreadCrumbService ThenPage(this IBreadCrumbService breadCrumbService, string title,
        string? page = default,
        string? handler = default,
        object? values = default,
        PathString? pathBase = default,
        FragmentString fragment = default,
        LinkOptions? options = default)

Overriding the default look

Create a directory in your project at the path Views/Shared/Components/BreadCrumbs (in your views/shared folder create a Components subdirectory and then a BreadCrumbs subdirectory). Copy the Views/Shared/Components/BreadCrumbs/Default.cshtml file from this project into that directory and customize how you wish.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 738 1/28/2022
1.0.2 406 1/28/2022
1.0.0.1 419 1/20/2022
0.0.0-alpha.0 127 1/20/2022