From 15d5ecfc808ee947bd13fca90e00d2b6ffcf82c2 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Fri, 15 Nov 2024 22:37:49 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(metadata):=20Global=20metada?= =?UTF-8?q?ta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/app/layout.tsx | 44 ++++++++++++++++++++++----------------- apps/user/app/layout.tsx | 44 ++++++++++++++++++++++----------------- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/apps/admin/app/layout.tsx b/apps/admin/app/layout.tsx index acaa0ba..ba5a858 100644 --- a/apps/admin/app/layout.tsx +++ b/apps/admin/app/layout.tsx @@ -13,25 +13,31 @@ import NextTopLoader from 'nextjs-toploader'; import React from 'react'; export async function generateMetadata(): Promise { - const config = await getGlobalConfig({ skipErrorHandler: true }).then((res) => res.data.data!); - const site = config.site || {}; - return { - title: { - default: `${site.site_name}`, - template: `%s | ${site.site_name}`, - }, - description: site.site_desc, - icons: { - icon: site.site_logo - ? [ - { - url: site.site_logo, - sizes: 'any', - }, - ] - : [], - }, - }; + try { + const config = await getGlobalConfig({ skipErrorHandler: true }).then((res) => res.data.data!); + const site = config.site || {}; + return { + title: { + default: `${site.site_name}`, + template: `%s | ${site.site_name}`, + }, + description: site.site_desc, + icons: { + icon: site.site_logo + ? [ + { + url: site.site_logo, + sizes: 'any', + }, + ] + : [], + }, + }; + } catch (error) { + return { + title: { default: 'PPanel', template: '%s | PPanel' }, + }; + } } export default async function RootLayout({ children }: { children: React.ReactNode }) { diff --git a/apps/user/app/layout.tsx b/apps/user/app/layout.tsx index b774a50..bd2c2c1 100644 --- a/apps/user/app/layout.tsx +++ b/apps/user/app/layout.tsx @@ -13,25 +13,31 @@ import NextTopLoader from 'nextjs-toploader'; import React from 'react'; export async function generateMetadata(): Promise { - const config = await getGlobalConfig({ skipErrorHandler: true }).then((res) => res.data.data!); - const site = config?.site || {}; - return { - title: { - default: `${site.site_name}`, - template: `%s | ${site.site_name}`, - }, - description: site.site_desc, - icons: { - icon: site.site_logo - ? [ - { - url: site.site_logo, - sizes: 'any', - }, - ] - : [], - }, - }; + try { + const config = await getGlobalConfig({ skipErrorHandler: true }).then((res) => res.data.data!); + const site = config.site || {}; + return { + title: { + default: `${site.site_name}`, + template: `%s | ${site.site_name}`, + }, + description: site.site_desc, + icons: { + icon: site.site_logo + ? [ + { + url: site.site_logo, + sizes: 'any', + }, + ] + : [], + }, + }; + } catch (error) { + return { + title: { default: 'PPanel', template: '%s | PPanel' }, + }; + } } export default async function RootLayout({ children }: { children: React.ReactNode }) {