feat: complete dynamic JSON-driven photo tools frontend connected to FastAPI backend
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
import { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { getAllApps, getAppBySlug, getAllTools, getTemplate } 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`,
|
||||
description: tagline,
|
||||
alternates: {
|
||||
canonical: `/apps/${app.slug}`,
|
||||
},
|
||||
openGraph: {
|
||||
title: `${name} — AI Photo Editing App`,
|
||||
description: tagline,
|
||||
type: 'website',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
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',
|
||||
};
|
||||
|
||||
// Structured Data (JSON-LD) per PRD §10 SEO-07
|
||||
const structuredData = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'SoftwareApplication',
|
||||
name: resolveLocalised(app.name, 'en'),
|
||||
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',
|
||||
},
|
||||
};
|
||||
|
||||
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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user