load logo in client
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled

This commit is contained in:
hamid zarghami
2026-06-03 22:25:26 +03:30
parent dc3646eef6
commit ace6a0b288
1870 changed files with 104 additions and 345 deletions
+18 -27
View File
@@ -17,24 +17,12 @@ export async function generateMetadata({
params: Promise<LayoutParams>
}): Promise<Metadata> {
const { name } = await params
const defaultIcon = "/icons/web-app-manifest-192x192.png"
const defaultIcon512 = "/icons/web-app-manifest-512x512.png"
try {
const restaurant = await getRestaurant(name)
const title = restaurant.seoTitle || restaurant.name
const logo = restaurant.logo
const defaultIcon = "/icons/web-app-manifest-192x192.png"
// استفاده از API route برای تبدیل لوگو به مربع
let iconUrl = defaultIcon
let icon192Url = defaultIcon
let icon512Url = "/icons/web-app-manifest-512x512.png"
if (logo && logo.trim() !== "") {
iconUrl = `/${name}/api/logo?url=${encodeURIComponent(logo)}&size=192`
icon192Url = `/${name}/api/logo?url=${encodeURIComponent(logo)}&size=192`
icon512Url = `/${name}/api/logo?url=${encodeURIComponent(logo)}&size=512`
}
return {
title,
@@ -42,12 +30,12 @@ export async function generateMetadata({
manifest: `/${name}/manifest.webmanifest`,
icons: {
icon: [
{ url: iconUrl },
{ url: icon192Url, sizes: "192x192", type: "image/png" },
{ url: icon512Url, sizes: "512x512", type: "image/png" },
{ url: defaultIcon },
{ url: defaultIcon, sizes: "192x192", type: "image/png" },
{ url: defaultIcon512, sizes: "512x512", type: "image/png" },
],
shortcut: iconUrl,
apple: iconUrl,
shortcut: defaultIcon,
apple: defaultIcon,
},
}
} catch {
@@ -94,18 +82,21 @@ export default async function Layout({
children: React.ReactNode
params: Promise<LayoutParams>
}): Promise<React.ReactNode> {
const { name } = await params
try {
const { name } = await params
await getRestaurant(name)
return <>
<PreferenceWrapper>{children}</PreferenceWrapper>
<CartChecker />
<ActiveChecker />
</>
} catch (error) {
if (error instanceof Error && error.message === 'RESTAURANT_NOT_FOUND') {
notFound()
}
throw error
}
return (
<>
<PreferenceWrapper>{children}</PreferenceWrapper>
<CartChecker />
<ActiveChecker />
</>
)
}