Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Blazor plugin extensions used by other CodeGator packages.

License

Notifications You must be signed in to change notification settings

CodeGator/CG.Blazor.Plugins

Repository files navigation

CG.Blazor.Plugins:


Build Status Github docs NuGet downloads Azure DevOps coverage Github discussion CG.Blazor.Plugins on fuget.org

What does it do?

The package contains server side Blazor plugin extensions used by other CodeGator packages.

Commonly used types:

  • Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions
  • CG.Blazor.Plugins.Plugins.IModule
  • CG.Blazor.Plugins.Plugins.ModuleBase
  • CG.Blazor.Plugins.Options.BlazorPluginOptions
  • CG.Blazor.Plugins.Options.BlazorModuleOptions

What platform(s) does it support?

  • .NET 6.x or higher

How do I install it?

The binary is hosted on NuGet. To install the package using the NuGet package manager:

PM> Install-Package CG.Blazor.Plugins

How do I contact you?

If you've spotted a bug in the code please use the project Issues HERE

We have a discussion group HERE

Is there any documentation?

There is developer documentation HERE

We also blog about projects like this one on our website, HERE


How do I get started?

There is a working quick start sample HERE

Steps to add plugins to a Blazor project:

  1. Create a Blazor project to suit your taste.

  2. Add the CG.Blazor.Plugins NUGET package to the project.

  3. Add the @using CG.Blazor.Plugins statement to the _Imports.razor file.

  4. Add the line: services.AddBlazorPlugins(Configuration.GetSection("Plugins")); to the ConfigureServices method of the Startup class.

  5. Add the line: app.UseBlazorPlugins(env); to the Configure method of the Startup class.

  6. Add the following to your appsettings.json file:

{
  "Plugins": {
    "Modules": [
      {
        "AssemblyNameOrPath": "YourPlugin",
        "Routed": true // <- true if you have pages that need routing support.
      }
    ]
  }
}

Where you will, of course, use the name of your plugin assembly in place of YourPlugin

  1. Edit the App.razor file like so:
<Router AppAssembly="@typeof(Program).Assembly" 
        PreferExactMatches="@true"
        [email protected]> // <-- this line
    // code removed for clarity.
</Router>

The indicated line should be added, so the framework will route properly for the plugins.

  1. Edit the _Host.cshtml file like so:

8A. Add the @using CG.Blazor.Plugins statement near the top of the file.

8B. Add the @(Html.Raw(BlazorResources.RenderStyleSheetLinks())) statement at the bottom of the head tag

8C. Add the @(Html.Raw(BlazorResources.RenderScriptTags())) statement at the bottom of the body tag.

  1. Create your plugin project and add a reference to that project to your Blazor project.

That's it! Of course, you could get fancier with things, if you like. But, this is enough to get started.

Disclaimer

This package and it's contents are experimental in nature. There is no official support. Use at your own risk.

About

Blazor plugin extensions used by other CodeGator packages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published