[backend/razor] Add instance icon and banner to home page

This commit is contained in:
pancakes 2025-03-29 14:24:26 +10:00
parent 8c50211efb
commit 93df8755ac
No known key found for this signature in database
3 changed files with 40 additions and 4 deletions

View file

@ -3,8 +3,6 @@
@* ReSharper disable Html.PathError *@ @* ReSharper disable Html.PathError *@
@{ @{
ViewData["title"] = $"Home - {Model.InstanceName}"; ViewData["title"] = $"Home - {Model.InstanceName}";
//TODO: logo / banner & favicon
} }
@section head @section head
@ -16,11 +14,23 @@
} }
<div class="header"> <div class="header">
<span>
@if (Model.IconUrl != null)
{
<img class="icon" src="@Model.IconUrl" alt="icon"/>
}
<h1>@Model.InstanceName</h1> <h1>@Model.InstanceName</h1>
</span>
<div class="wordmark"> <div class="wordmark">
<img src="~/_content/Iceshrimp.Assets.Branding/welcome-logo.svg" alt="Iceshrimp"/> <img src="~/_content/Iceshrimp.Assets.Branding/welcome-logo.svg" alt="Iceshrimp"/>
</div> </div>
</div> </div>
@if (Model.BannerUrl != null)
{
<img class="banner" src="@Model.BannerUrl" alt="banner"/>
}
<p>@Model.InstanceDescription</p> <p>@Model.InstanceDescription</p>
@if (Model.Rules.Count != 0) @if (Model.Rules.Count != 0)

View file

@ -13,6 +13,8 @@ public class IndexModel(MetaService meta, InstanceService instance, IOptionsSnap
public string? ContactEmail; public string? ContactEmail;
public string InstanceDescription = null!; public string InstanceDescription = null!;
public string InstanceName = null!; public string InstanceName = null!;
public string? IconUrl;
public string? BannerUrl;
public List<Rule> Rules = []; public List<Rule> Rules = [];
public async Task<IActionResult> OnGet() public async Task<IActionResult> OnGet()
@ -32,6 +34,8 @@ public class IndexModel(MetaService meta, InstanceService instance, IOptionsSnap
instanceDescription ?? "This Iceshrimp.NET instance does not appear to have a description"; instanceDescription ?? "This Iceshrimp.NET instance does not appear to have a description";
ContactEmail = contactEmail; ContactEmail = contactEmail;
(IconUrl, BannerUrl) = await instance.GetInstanceImageAsync();
Rules = await instance.GetRulesAsync(); Rules = await instance.GetRulesAsync();
return Page(); return Page();

View file

@ -8,12 +8,34 @@
gap: 0 12px; gap: 0 12px;
} }
.header>h1 { .header span {
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.header h1 {
margin: 0; margin: 0;
} }
.header .icon {
width: 3rem;
height: 3rem;
border-radius: 8px;
line-height: 1;
}
.header>.wordmark { .header>.wordmark {
width: 160px; width: 160px;
line-height: 0; line-height: 0;
padding-bottom: 4px; padding-bottom: 4px;
} }
.banner {
display: block;
width: 100%;
height: auto;
object-fit: cover;
aspect-ratio: 21/9;
border-radius: 1rem;
}