AllAi/apps/web/app/[locale]/blog/page.tsx
2025-11-14 21:54:04 +03:00

99 lines
2.7 KiB
TypeScript

import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { loadDictionary } from "@allai/i18n/server";
import { locales, resolveLocale } from "@/config/i18n";
import { BlogPage } from "@/features/marketing/BlogPage";
import { blogPosts } from "@/features/marketing/blogData";
import { absoluteUrl, buildCanonical, buildLocaleAlternates, buildOpenGraph, buildTwitterCard } from "@/seo/seoUtils";
const PATH = "/blog" as const;
type PageProps = {
params: { locale: string };
};
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
const locale = resolveLocale(params.locale);
if (!locales.includes(locale)) {
return {
title: "AllAI blog"
};
}
const dictionary = await loadDictionary(locale);
const title = `Blog | ${dictionary.common.brandLong ?? dictionary.common.brandShort}`;
const description =
"Insights, playbooks, and case studies on running AI-first creative production with AllAI Studio.";
return {
title,
description,
alternates: {
canonical: buildCanonical(locale, PATH),
languages: buildLocaleAlternates(PATH)
},
openGraph: buildOpenGraph({
locale,
title,
description,
path: PATH
}),
twitter: buildTwitterCard({
title,
description
})
};
}
export default async function BlogRoute({ params }: PageProps) {
const locale = resolveLocale(params.locale);
if (!locales.includes(locale)) {
notFound();
}
const dictionary = await loadDictionary(locale);
const canonical = buildCanonical(locale, PATH);
const publisher = {
"@type": "Organization",
name: dictionary.common.brandLong ?? dictionary.common.brandShort,
logo: {
"@type": "ImageObject",
url: absoluteUrl("/favicon.ico")
}
};
const structuredData = {
"@context": "https://schema.org",
"@type": "Blog",
name: `${dictionary.common.brandLong ?? dictionary.common.brandShort} insights`,
description:
"Expert commentary and tutorials for creative teams adopting generative AI workflows with AllAI Studio.",
url: canonical,
inLanguage: locale,
publisher,
blogPost: blogPosts.map((post) => ({
"@type": "BlogPosting",
headline: post.title,
description: post.excerpt,
url: buildCanonical(locale, `${PATH}/${post.slug}`),
datePublished: post.publishedAt,
dateModified: post.publishedAt,
author: publisher,
publisher
}))
};
return (
<>
<script
type="application/ld+json"
suppressHydrationWarning
dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}
/>
<BlogPage locale={locale} />
</>
);
}