Skip to content

Create professional demos and 3D mockups in seconds, directly in your browser

perf(seo): scope client messages per route and render native JSON-LD

CristianOlivera1826469be063f
diff --git a/app/[locale]/(auth)/layout.tsx b/app/[locale]/(auth)/layout.tsx
index 47f4c14..b8ee58e 100644
--- a/app/[locale]/(auth)/layout.tsx
+++ b/app/[locale]/(auth)/layout.tsx
@@ -1,7 +1,14 @@
-export default function AuthLayout({ children }: { children: React.ReactNode }) {
+import { NextIntlClientProvider } from "next-intl";
+import { getMessages } from "next-intl/server";
+
+export default async function AuthLayout({ children }: { children: React.ReactNode }) {
+ const messages = await getMessages();
+
return (
- <div className="min-h-screen bg-neutral-950">
- {children}
- </div>
+ <NextIntlClientProvider messages={messages}>
+ <div className="min-h-screen bg-neutral-950">
+ {children}
+ </div>
+ </NextIntlClientProvider>
);
}
diff --git a/app/[locale]/(editor)/editor/layout.tsx b/app/[locale]/(editor)/editor/layout.tsx
index 3435fe2..eda2010 100644
--- a/app/[locale]/(editor)/editor/layout.tsx
+++ b/app/[locale]/(editor)/editor/layout.tsx
@@ -1,4 +1,6 @@
import type { Metadata } from "next";
+import { NextIntlClientProvider } from "next-intl";
+import { getMessages } from "next-intl/server";
export const metadata: Metadata = {
robots: {
@@ -7,6 +9,12 @@ export const metadata: Metadata = {
},
};
-export default function EditorRouteLayout({ children }: { children: React.ReactNode }) {
- return <>{children}</>;
+export default async function EditorRouteLayout({ children }: { children: React.ReactNode }) {
+ const messages = await getMessages();
+
+ return (
+ <NextIntlClientProvider messages={messages}>
+ {children}
+ </NextIntlClientProvider>
+ );
}
\ No newline at end of file
diff --git a/app/[locale]/(home)/page.tsx b/app/[locale]/(home)/page.tsx
index cbe6137..7424c70 100644
--- a/app/[locale]/(home)/page.tsx
+++ b/app/[locale]/(home)/page.tsx
@@ -1,6 +1,6 @@
import Hero from "@/app/components/ui/home/Hero";
import InteractiveRecordingSteps from "@/app/components/ui/home/RecordingSteps";
-import { StructuredData, generateWebAppSchema, generateOrganizationSchema } from "@/app/components/seo/StructuredData";
+import { StructuredData, generateWebAppSchema, generateOrganizationSchema, generateWebSiteSchema } from "@/app/components/seo/StructuredData";
import type { Metadata } from 'next';
import DonationCard from "@/app/components/ui/home/DonationCard";
import VideoHero from "@/app/components/ui/home/VideoHero";
@@ -100,6 +100,7 @@ export default async function Home({ params }: Props) {
return (
<>
<StructuredData data={generateWebAppSchema(locale as 'en' | 'es' | 'ru' | 'ko')} />
+ <StructuredData data={generateWebSiteSchema(locale as 'en' | 'es' | 'ru' | 'ko')} />
<StructuredData data={generateOrganizationSchema()} />
<div className="flex flex-col">
diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx
index 7c4074b..98e1a1a 100644
--- a/app/[locale]/layout.tsx
+++ b/app/[locale]/layout.tsx
@@ -130,7 +130,20 @@ export default async function LocaleLayout({
}
setRequestLocale(locale);
- const messages = await getMessages();
+ const messages = (await getMessages()) as Record<string, unknown>;
+ const publicMessages = {
+ header: messages.header,
+ footer: messages.footer,
+ userMenu: messages.userMenu,
+ recording: messages.recording,
+ hero: messages.hero,
+ demo: messages.demo,
+ featuresShowcase: messages.featuresShowcase,
+ featuresGrid: messages.featuresGrid,
+ socialReactions: messages.socialReactions,
+ donation: messages.donation,
+ notFound: messages.notFound,
+ };
const isProduction = process.env.NODE_ENV === 'production';
const gaId = process.env.NEXT_PUBLIC_GA_ID;
@@ -144,7 +157,7 @@ export default async function LocaleLayout({
`}
>
<meta httpEquiv="content-language" content={locale} />
- <NextIntlClientProvider key={locale} messages={messages} locale={locale}>
+ <NextIntlClientProvider key={locale} messages={publicMessages} locale={locale}>
<TooltipProvider delayDuration={200}>
{children}
</TooltipProvider>
diff --git a/app/components/seo/StructuredData.tsx b/app/components/seo/StructuredData.tsx
index 236149c..557cb61 100644
--- a/app/components/seo/StructuredData.tsx
+++ b/app/components/seo/StructuredData.tsx
@@ -1,5 +1,3 @@
-import Script from 'next/script';
-
type WebApplicationSchema = {
'@context': 'https://schema.org';
'@type': 'WebApplication';
@@ -13,6 +11,7 @@ type WebApplicationSchema = {
};
description: string;
url: string;
+ inLanguage?: string;
image?: string;
author?: {
'@type': 'Organization' | 'Person';
@@ -36,6 +35,21 @@ type OrganizationSchema = {
};
};
+type WebSiteSchema = {
+ '@context': 'https://schema.org';
+ '@type': 'WebSite';
+ name: string;
+ alternateName?: string;
+ url: string;
+ inLanguage?: string;
+ publisher?: {
+ '@type': 'Organization';
+ name: string;
+ url: string;
+ logo?: string;
+ };
+};
+
type BreadcrumbSchema = {
'@context': 'https://schema.org';
'@type': 'BreadcrumbList';
@@ -48,16 +62,15 @@ type BreadcrumbSchema = {
};
type StructuredDataProps = {
- data: WebApplicationSchema | OrganizationSchema | BreadcrumbSchema | Record<string, unknown>;
+ data: WebApplicationSchema | OrganizationSchema | WebSiteSchema | BreadcrumbSchema | Record<string, unknown>;
};
export function StructuredData({ data }: StructuredDataProps) {
return (
- <Script
+ <script
id={`structured-data-${data['@type']}`}
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }}
- strategy="beforeInteractive"
/>
);
}
@@ -131,6 +144,7 @@ export function generateWebAppSchema(locale: 'es' | 'en' | 'ru' | 'ko'): WebAppl
},
description,
url: baseUrl,
+ inLanguage: locale,
image: `${baseUrl}/images/metadata/preview-openvid.jpg`,
author: {
'@type': 'Person',
@@ -141,8 +155,7 @@ export function generateWebAppSchema(locale: 'es' | 'en' | 'ru' | 'ko'): WebAppl
};
}
-export function generateOrganizationSchema(): OrganizationSchema {
- return {
+export function generateOrganizationSchema(): OrganizationSchema { return {
'@context': 'https://schema.org',
'@type': 'Organization',
name: 'openvid',
@@ -162,3 +175,20 @@ export function generateOrganizationSchema(): OrganizationSchema {
},
};
}
+
+export function generateWebSiteSchema(locale: 'es' | 'en' | 'ru' | 'ko'): WebSiteSchema {
+ return {
+ '@context': 'https://schema.org',
+ '@type': 'WebSite',
+ name: 'OpenVid',
+ alternateName: 'openvid',
+ url: 'https://openvid.dev',
+ inLanguage: locale,
+ publisher: {
+ '@type': 'Organization',
+ name: 'openvid',
+ url: 'https://openvid.dev',
+ logo: 'https://openvid.dev/images/metadata/favicon.svg',
+ },
+ };
+}