remove ssr

This commit is contained in:
hamid zarghami
2026-06-06 10:17:29 +03:30
parent 2ae99faca9
commit 4e48ce7214
10 changed files with 486 additions and 402 deletions
+70
View File
@@ -0,0 +1,70 @@
import type { Metadata, Viewport } from "next";
import { PWA_ICON_192, PWA_ICON_512 } from "@/lib/helpers/pwaIcons";
import { getRestaurant } from "./getRestaurant";
export async function buildRestaurantMetadata(name: string): Promise<Metadata> {
const defaultIcon = PWA_ICON_192;
const defaultIcon512 = PWA_ICON_512;
try {
const restaurant = await getRestaurant(name);
const title = restaurant.seoTitle || restaurant.name;
const logo = restaurant.logo;
let iconUrl = defaultIcon;
let icon192Url = defaultIcon;
let icon512Url = defaultIcon512;
if (logo && logo.trim() !== "") {
iconUrl = `/${name}/api/logo?url=${encodeURIComponent(logo)}&size=192`;
icon192Url = iconUrl;
icon512Url = `/${name}/api/logo?url=${encodeURIComponent(logo)}&size=512`;
}
return {
title,
description:
restaurant.seoDescription ||
restaurant.description ||
`منوی ${restaurant.name}`,
manifest: `/${name}/manifest.webmanifest`,
icons: {
icon: [
{ url: iconUrl },
{ url: icon192Url, sizes: "192x192", type: "image/png" },
{ url: icon512Url, sizes: "512x512", type: "image/png" },
],
shortcut: iconUrl,
apple: iconUrl,
},
};
} catch {
return {
title: `${name} - Dashboard`,
description: `PWA dashboard for ${name}`,
manifest: `/${name}/manifest.webmanifest`,
icons: {
icon: [
{ url: PWA_ICON_192 },
{ url: PWA_ICON_192, sizes: "192x192", type: "image/png" },
{ url: PWA_ICON_512, sizes: "512x512", type: "image/png" },
],
shortcut: PWA_ICON_192,
apple: PWA_ICON_192,
},
};
}
}
export async function buildRestaurantViewport(name: string): Promise<Viewport> {
try {
const restaurant = await getRestaurant(name);
return {
themeColor: restaurant.menuColor || "#F4F5F9",
};
} catch {
return {
themeColor: "#F4F5F9",
};
}
}