117 lines
3.1 KiB
TypeScript
117 lines
3.1 KiB
TypeScript
import { Metadata } from 'next';
|
|
import { notFound } from 'next/navigation';
|
|
import { getAllApps, getAppBySlug, getAllTools, getTemplate, getSiteConfig } from '@/lib/config/loader';
|
|
import { SectionRenderer } from '@/components/sections/SectionRenderer';
|
|
import { resolveLocalised } from '@/types';
|
|
|
|
interface AppPageProps {
|
|
params: { slug: string };
|
|
}
|
|
|
|
export async function generateStaticParams() {
|
|
const apps = getAllApps();
|
|
return apps.map((a) => ({ slug: a.slug }));
|
|
}
|
|
|
|
export async function generateMetadata({ params }: AppPageProps): Promise<Metadata> {
|
|
const app = getAppBySlug(params.slug);
|
|
if (!app) return {};
|
|
|
|
const name = resolveLocalised(app.name, 'en');
|
|
const tagline = resolveLocalised(app.tagline, 'en');
|
|
|
|
return {
|
|
title: `${name} | Official Mobile App Download | CRE Innovations`,
|
|
description: tagline,
|
|
alternates: {
|
|
canonical: `/apps/${app.slug}`,
|
|
},
|
|
openGraph: {
|
|
title: `${name} — AI Photo Editing App | CRE Innovations`,
|
|
description: tagline,
|
|
type: 'website',
|
|
},
|
|
twitter: {
|
|
card: 'summary_large_image',
|
|
title: `${name} | CRE Innovations`,
|
|
description: tagline,
|
|
},
|
|
};
|
|
}
|
|
|
|
export default function AppDetailPage({ params }: AppPageProps) {
|
|
const app = getAppBySlug(params.slug);
|
|
if (!app) notFound();
|
|
|
|
const template = getTemplate('app') || { sections: [] };
|
|
const allTools = getAllTools();
|
|
const appTools = allTools.filter((t) => app.tools.includes(t.id));
|
|
|
|
const context = {
|
|
app,
|
|
tools: appTools,
|
|
locale: 'en',
|
|
};
|
|
|
|
const appName = resolveLocalised(app.name, 'en');
|
|
const appTagline = resolveLocalised(app.tagline, 'en');
|
|
const siteUrl = (process.env.SITE_URL || getSiteConfig().seo.siteUrl || 'http://localhost:3000').replace(/\/$/, '');
|
|
|
|
// Structured Data (JSON-LD) per PRD §10 SEO-07
|
|
const structuredData = [
|
|
{
|
|
'@context': 'https://schema.org',
|
|
'@type': 'SoftwareApplication',
|
|
name: appName,
|
|
operatingSystem: 'ANDROID, IOS',
|
|
applicationCategory: 'MultimediaApplication',
|
|
aggregateRating: {
|
|
'@type': 'AggregateRating',
|
|
ratingValue: app.rating.value.toString(),
|
|
ratingCount: app.rating.count.toString(),
|
|
},
|
|
offers: {
|
|
'@type': 'Offer',
|
|
price: '0',
|
|
priceCurrency: 'USD',
|
|
},
|
|
},
|
|
{
|
|
'@context': 'https://schema.org',
|
|
'@type': 'BreadcrumbList',
|
|
itemListElement: [
|
|
{
|
|
'@type': 'ListItem',
|
|
position: 1,
|
|
name: 'Home',
|
|
item: siteUrl,
|
|
},
|
|
{
|
|
'@type': 'ListItem',
|
|
position: 2,
|
|
name: 'Apps',
|
|
item: `${siteUrl}/apps`,
|
|
},
|
|
{
|
|
'@type': 'ListItem',
|
|
position: 3,
|
|
name: appName,
|
|
item: `${siteUrl}/apps/${app.slug}`,
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
return (
|
|
<div>
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}
|
|
/>
|
|
{template.sections.map((section: any) => (
|
|
<SectionRenderer key={section.id} section={section} context={context} />
|
|
))}
|
|
</div>
|
|
);
|
|
}
|