Giter Club home page Giter Club logo

blazorchard's Introduction

BlazOrchard

This repo gives an example of how to set up a solution to run an OrchardCore Decoupled CMS, with a Blazor Web App front-end.

Reproduction Steps

This is the easiest way I've found to get started:

  1. Create a .NET Blazor Web App, with whatever interactivity you want.

  2. In a separate window, create a new OrchardCore CMS App.

  3. Copy NLog.config from the Orchard site, into the Blazor site.

  4. Copy the settings from the Orchard site project file, into the Blazor site:

	<PropertyGroup>
		<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
	</PropertyGroup>
	<ItemGroup>
		<Watch 
		    Include="**\*.cs"
		    Exclude="Recipes\**;Assets\**;node_modules\**\*;**\*.js.map;obj\**\*;bin\**\*" />
	</ItemGroup>
	<ItemGroup>
		<PackageReference Include="OrchardCore.Logging.NLog" Version="1.8.2" />
		<PackageReference Include="OrchardCore.Application.Cms.Targets" Version="1.8.2" />
	</ItemGroup>
  1. Add OrchardCore to the builder in Program.cs, and move (not copy) your Blazor services and pipelines into the Orchard configuration.
builder.Host.UseNLogHost();
builder.Services
    .AddOrchardCms()
    .ConfigureServices(services =>
    {
        services.AddRazorComponents()
            .AddInteractiveServerComponents()
            .AddInteractiveWebAssemblyComponents();
    })
    .Configure((app, routes, _) =>
    {
        app.UseStaticFiles();
        app.UseAntiforgery();
        //routes.MapRazorComponents<App>()
        //    .AddInteractiveServerRenderMode()
        //    .AddInteractiveWebAssemblyRenderMode()
        //    .AddAdditionalAssemblies(typeof(BlazOrchard.BlazorWebApp.Client._Imports).Assembly);
    })
    ;  

This is the most counter-intuitive step. It's Orchard that will be handling, serving, and routing the pipelines, not Blazor. It uses the mappings within its own router, configured here. We've left it commented out here, so we can first set up OrchardCore.

  1. Add the OrchardCore middleware, last in the chain, before running the app:
app.UseOrchardCore();
app.Run();
  1. Run the application, and you'll see the familiar OrchardCore setup screen. Go through setup as normal. You can choose any recipe you like, as the front-end will be re-routed anyway. It's common to choose Headless CMS here, so that no front-end theme is added at all.

  2. Uncomment the Blazor mappings from the Orchard router, and launch your app. You should see a fully working Blazor sample app, with working counter, and weather pages.

  3. Head to /admin to log into the OrchardCore backend.

blazorchard's People

Contributors

apachetech avatar

Stargazers

Dave Black avatar Zig avatar Osvaldo avatar  avatar Drew Brasher avatar

Watchers

Osvaldo avatar  avatar Drew Brasher avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.