Getting started
Note
All four steps work today: pages show their published content, or else their markup defaults, and signed-in editors can edit text, rich text and images on the live page.
1. Add the packages
Add the core package and a storage package from the HCI NuGet feed. SQL Server is the default; for a site with no database server, use HCI.SunBird.Data.Sqlite and UseSqlite(...) instead:
dotnet add package HCI.SunBird
dotnet add package HCI.SunBird.Data.SqlServer
2. Register SunBird
In Program.cs:
using HCI.SunBird.Data.SqlServer;
using HCI.SunBird.Web;
builder.Services.AddSendGridEmail(builder.Configuration); // SunBird emails invites and password resets
builder.Services.AddAzureBlobStorage(builder.Configuration); // SunBird keeps uploaded images here
builder.AddSunBird().UseSqlServer(builder.Configuration.GetConnectionString("SunBird")!);
var app = builder.Build();
app.MapSunBird(); // applies SunBird's database migrations on start
See Store content in SQL Server or Store content in SQLite for the connection string, what SunBird needs from the database, and the tables it creates. Set SunBird:SiteUrl and SunBird:Email:From too; see Sign in and manage editors for email, and Store images for the file store.
3. Make a page editable
Give the page a key with [SunBirdPage] on its PageModel (using HCI.SunBird.Web;):
[SunBirdPage("home")]
public class IndexModel : PageModel
{
}
Register the tag helpers once, in Pages/_ViewImports.cshtml:
@addTagHelper *, HCI.SunBird
Then mark the editable parts of the page. The content inside each tag is the default, shown until an editor publishes a value:
<h1><sb-text key="hero-title">Build calm, fast websites</sb-text></h1>
<sb-html key="hero-intro"><p>A short introduction.</p></sb-html>
<sb-image key="hero-image" src="/img/hero.jpg" alt="Our office" />
See Make a page editable for partials, images and what the tags render, and Pages and slots for the rules on keys and defaults.
4. Create the first admin
Set a setup code as the SunBird:SetupCode setting (an App Service setting, or user secrets locally; never in source control), then open /sunbird/setup and create the first admin account. See Sign in and manage editors.