Add EHSAN favicon and localized browser tab titles (Task #21)

The browser tab previously showed a generic placeholder favicon and the
English title "EHSAN Closed Donation Loop". Per the reference, the tab now
shows the EHSAN logo mark and an Arabic platform title.

Changes:
- Favicon: copied the existing EHSAN logo (src/assets/ehsan-logo.png) to
  public/favicon.png and pointed index.html at %BASE_URL%favicon.png
  (base-path safe; verified it serves 200 image/png).
- Static head: index.html <title> and OG/Twitter titles + description now
  use the Arabic platform name "منصة إحسان".
- Per-page titles: added a DocumentTitle component
  (src/hooks/useDocumentTitle.ts) rendered in the Router that sets
  document.title to "<page name> - <platform>" based on the current wouter
  path and active language, reading from a new translations.meta section
  (AR + EN). Home reads "الصفحة الرئيسية - منصة إحسان"; switches with language.

Approach note: titles are centralized in the router rather than edited into
each page file, keeping it DRY while covering all main routes.

Verified: tsc clean; e2e confirmed titles on /, /opportunities, /cart and
English fallback ("Home - EHSAN Platform"), plus favicon load.
This commit is contained in:
Replit Agent
2026-06-05 20:23:22 +00:00
parent f876f8474d
commit 0c2ef37622
5 changed files with 74 additions and 7 deletions
+7 -7
View File
@@ -3,16 +3,16 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
<title>EHSAN Closed Donation Loop</title> <title>منصة إحسان</title>
<meta name="description" content="EHSAN Closed Donation Loop — built on Replit. Update this description to reflect the app." /> <meta name="description" content="منصة إحسان — المنصة الوطنية للعمل الخيري والتنموي." />
<meta name="robots" content="index, follow" /> <meta name="robots" content="index, follow" />
<meta property="og:title" content="EHSAN Closed Donation Loop" /> <meta property="og:title" content="منصة إحسان" />
<meta property="og:description" content="EHSAN Closed Donation Loop — built on Replit. Update this description to reflect the app." /> <meta property="og:description" content="منصة إحسان — المنصة الوطنية للعمل الخيري والتنموي." />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="EHSAN Closed Donation Loop" /> <meta name="twitter:title" content="منصة إحسان" />
<meta name="twitter:description" content="EHSAN Closed Donation Loop — built on Replit. Update this description to reflect the app." /> <meta name="twitter:description" content="منصة إحسان — المنصة الوطنية للعمل الخيري والتنموي." />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="icon" type="image/png" href="%BASE_URL%favicon.png" />
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap" rel="stylesheet">
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+2
View File
@@ -6,6 +6,7 @@ import { LanguageProvider } from "./contexts/LanguageContext";
import { CartProvider } from "./contexts/CartContext"; import { CartProvider } from "./contexts/CartContext";
import { AuthProvider, useAuth } from "./contexts/AuthContext"; import { AuthProvider, useAuth } from "./contexts/AuthContext";
import { AppLayout } from "./components/layout/AppLayout"; import { AppLayout } from "./components/layout/AppLayout";
import { DocumentTitle } from "./hooks/useDocumentTitle";
import NotFound from "@/pages/not-found"; import NotFound from "@/pages/not-found";
import { ComponentType } from "react"; import { ComponentType } from "react";
@@ -37,6 +38,7 @@ function Protected({ component: Component }: { component: ComponentType<any> })
function Router() { function Router() {
return ( return (
<AppLayout> <AppLayout>
<DocumentTitle />
<Switch> <Switch>
<Route path="/" component={Home} /> <Route path="/" component={Home} />
<Route path="/about/:section?" component={About} /> <Route path="/about/:section?" component={About} />
@@ -0,0 +1,33 @@
import { useEffect } from "react";
import { useLocation } from "wouter";
import { useLanguage } from "../contexts/LanguageContext";
function pageNameForPath(path: string, meta: Record<string, string>): string {
if (path === "/" || path === "") return meta.home;
if (path.startsWith("/opportunities")) return meta.opportunities;
if (path.startsWith("/cart")) return meta.cart;
if (path.startsWith("/about")) return meta.about;
if (path.startsWith("/track")) return meta.track;
if (path.startsWith("/donate")) return meta.donate;
if (path.startsWith("/request")) return meta.request;
if (path.startsWith("/waqf")) return meta.waqf;
if (path.startsWith("/baraem")) return meta.baraem;
if (path.startsWith("/admin")) return meta.admin;
if (path.startsWith("/whatsapp-log")) return meta.whatsappLog;
if (path.startsWith("/thank-you")) return meta.thankYou;
if (path.startsWith("/login")) return meta.login;
return "";
}
export function DocumentTitle() {
const [location] = useLocation();
const { t } = useLanguage();
useEffect(() => {
const meta = t.meta as Record<string, string>;
const name = pageNameForPath(location, meta);
document.title = name ? `${name} - ${meta.platform}` : meta.platform;
}, [location, t]);
return null;
}
@@ -1,4 +1,20 @@
export const en = { export const en = {
meta: {
platform: "EHSAN Platform",
home: "Home",
opportunities: "Donation Opportunities",
cart: "Your Donation Cart",
about: "About EHSAN",
track: "Track Case",
donate: "Complete Donation",
request: "Request Support",
waqf: "Endowment",
baraem: "EHSAN Buds",
admin: "Admin Dashboard",
whatsappLog: "WhatsApp Log",
thankYou: "Submit Thank You",
login: "Login",
},
common: { common: {
ehsan: "EHSAN", ehsan: "EHSAN",
home: "Home", home: "Home",
@@ -400,6 +416,22 @@ export const en = {
}; };
export const ar = { export const ar = {
meta: {
platform: "منصة إحسان",
home: "الصفحة الرئيسية",
opportunities: "فرص التبرع",
cart: "سلة تبرعاتك",
about: "عن إحسان",
track: "تتبع الحالة",
donate: "إتمام التبرع",
request: "طلب دعم",
waqf: "الوقف",
baraem: "براعم إحسان",
admin: "لوحة الإدارة",
whatsappLog: "سجل واتساب",
thankYou: "إرسال شكر",
login: "تسجيل الدخول",
},
common: { common: {
ehsan: "إحسان", ehsan: "إحسان",
home: "الرئيسية", home: "الرئيسية",