feat: logo and favicon management in admin panel
CI/CD / CI · dotnet build (push) Successful in 41s
CI/CD / Deploy · drsousan (push) Successful in 29s

Admin panel:
- New 'هویت سایت' page under تنظیمات in sidebar
- Upload logo (PNG transparent, 200×60px recommended)
- Upload favicon (PNG/ICO, 32×32 or 64×64px)
- Live preview panel shows how logo looks in header
  and how favicon looks in a browser tab mockup
- Saved to SiteSettings with section='identity', key='logo'/'favicon'

Frontend (_Layout.cshtml):
- Injects AppDbContext to load identity settings per request
- If logo is set: shows <img> in header instead of text
- If favicon is set: uses uploaded file as <link rel="icon">
- Falls back to text / favicon.ico when not configured

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-02 17:47:49 +03:30
parent 81838f75ce
commit e79ccf7e8c
2 changed files with 157 additions and 3 deletions
+28 -2
View File
@@ -1,3 +1,12 @@
@using Microsoft.EntityFrameworkCore
@inject DrSousan.Api.Data.AppDbContext _layoutDb
@{
var _identity = await _layoutDb.SiteSettings
.Where(s => s.Section == "identity")
.ToListAsync();
var _logoUrl = _identity.FirstOrDefault(s => s.Key == "logo")?.Value ?? "";
var _faviconUrl = _identity.FirstOrDefault(s => s.Key == "favicon")?.Value ?? "";
}
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
@@ -8,7 +17,15 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap" onload="this.rel='stylesheet'" />
<noscript><link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap" rel="stylesheet" /></noscript>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
@if (!string.IsNullOrEmpty(_faviconUrl))
{
<link rel="icon" href="@_faviconUrl" type="image/png" />
<link rel="shortcut icon" href="@_faviconUrl" />
}
else
{
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
}
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
@@ -122,7 +139,16 @@
<body>
<header>
<a class="logo" href="/">@(ViewData["SiteName"] ?? "دکتر سوسن آل‌طه")</a>
<a class="logo" href="/">
@if (!string.IsNullOrEmpty(_logoUrl))
{
<img src="@_logoUrl" alt="@(ViewData["SiteName"] ?? "دکتر سوسن آل‌طه")" style="height:38px;width:auto;object-fit:contain;vertical-align:middle" />
}
else
{
@(ViewData["SiteName"] ?? "دکتر سوسن آل‌طه")
}
</a>
<nav>
<a href="/#about">درباره من</a>
<a href="/#services">خدمات</a>