Optimize content fetching and update configurations
Content fetching in the marketing section has been refactored to utilize the Next.js cache, which significantly improves performance. The date format of publishedAt has been updated to be more consistent across files. Code related to CSRF token, fonts, and metadata has been refactored into separate files for easier maintenance and readability.
This commit is contained in:
@@ -1,32 +1,17 @@
|
||||
import { Urbanist as HeadingFont, Inter as SansFont } from 'next/font/google';
|
||||
import Head from 'next/head';
|
||||
import { cookies, headers } from 'next/headers';
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
import { Toaster } from '@kit/ui/sonner';
|
||||
import { cn } from '@kit/ui/utils';
|
||||
|
||||
import { CsrfTokenMeta } from '~/components/csrf-token-meta';
|
||||
import { RootProviders } from '~/components/root-providers';
|
||||
import appConfig from '~/config/app.config';
|
||||
import { heading, sans } from '~/lib/fonts';
|
||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||
import { rootMetadata } from '~/lib/root-metdata';
|
||||
|
||||
import '../styles/globals.css';
|
||||
|
||||
const sans = SansFont({
|
||||
subsets: ['latin'],
|
||||
variable: '--font-sans',
|
||||
fallback: ['system-ui', 'Helvetica Neue', 'Helvetica', 'Arial'],
|
||||
preload: true,
|
||||
weight: ['300', '400', '500', '600', '700'],
|
||||
});
|
||||
|
||||
const heading = HeadingFont({
|
||||
subsets: ['latin'],
|
||||
variable: '--font-heading',
|
||||
fallback: ['system-ui', 'Helvetica Neue', 'Helvetica', 'Arial'],
|
||||
preload: true,
|
||||
weight: ['500', '700'],
|
||||
});
|
||||
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
@@ -34,9 +19,10 @@ export default async function RootLayout({
|
||||
}) {
|
||||
const { language } = await createI18nServerInstance();
|
||||
const theme = getTheme();
|
||||
const className = getClassName(theme);
|
||||
|
||||
return (
|
||||
<html lang={language} className={getClassName(theme)}>
|
||||
<html lang={language} className={className}>
|
||||
<Head>
|
||||
<CsrfTokenMeta />
|
||||
</Head>
|
||||
@@ -71,33 +57,4 @@ function getTheme() {
|
||||
return cookies().get('theme')?.value;
|
||||
}
|
||||
|
||||
export const metadata = {
|
||||
title: appConfig.name,
|
||||
description: appConfig.description,
|
||||
metadataBase: new URL(appConfig.url),
|
||||
openGraph: {
|
||||
url: appConfig.url,
|
||||
siteName: appConfig.name,
|
||||
description: appConfig.description,
|
||||
},
|
||||
twitter: {
|
||||
card: 'summary_large_image',
|
||||
title: appConfig.title,
|
||||
description: appConfig.description,
|
||||
},
|
||||
icons: {
|
||||
icon: '/images/favicon/favicon.ico',
|
||||
shortcut: '/shortcut-icon.png',
|
||||
apple: '/images/favicon/apple-touch-icon.png',
|
||||
other: {
|
||||
rel: 'apple-touch-icon-precomposed',
|
||||
url: '/apple-touch-icon-precomposed.png',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
function CsrfTokenMeta() {
|
||||
const csrf = headers().get('x-csrf-token') ?? '';
|
||||
|
||||
return <meta content={csrf} name="csrf-token" />;
|
||||
}
|
||||
export const metadata = rootMetadata;
|
||||
|
||||
Reference in New Issue
Block a user