MotorSignal-App/website/lib/cms.ts

200 lines
5.6 KiB
TypeScript

export interface HomepageHeroContent {
headline: string;
subheadline: string;
cta_text: string;
cta_link: string;
badge_text: string;
}
export interface FeatureItem {
title: string;
description: string;
icon: string;
}
export interface FeaturesContent {
pillars_title?: string;
pillars_subtitle?: string;
items: FeatureItem[];
}
export interface DownloadLinksContent {
android_url: string;
testflight_url: string;
play_store_url: string;
version_name: string;
build_number: number;
}
export interface PolicyPagesContent {
privacy_policy: string;
terms_of_service: string;
}
export interface FaqItem {
question: string;
answer: string;
}
export interface FaqsContent {
items: FaqItem[];
}
export interface ScreenshotItem {
title: string;
caption: string;
image_url: string;
}
export interface ScreenshotsContent {
items: ScreenshotItem[];
}
export interface ReleaseItem {
version: string;
release_date: string;
title: string;
notes: string;
}
export interface ChangelogContent {
releases: ReleaseItem[];
}
export const DEFAULT_HOMEPAGE_HERO: HomepageHeroContent = {
headline: 'Know what your ride is doing.',
subheadline:
'MotorSignal turns every ride into clear, actionable insight: real-time lean angle, live GPS track telemetry on the road, post-session performance replay, and enterprise security for riders and clubs.',
cta_text: 'Create your account',
cta_link: '/register',
badge_text: '⚡ Next-Gen Telemetry Engine 3.0 • Real-Time CAN-Bus & GPS',
};
export const DEFAULT_FEATURES: FeaturesContent = {
pillars_title: 'Built for extreme lean angles & split-second decisions.',
pillars_subtitle:
'A bespoke telemetry suite connecting ECU sensors, gyroscopes, and track positioning straight to riders and crew chiefs.',
items: [
{
title: 'Live Cockpit & Handlebar HUD',
description:
'Real-time pitch, roll, yaw, throttle position, braking pressure, and predictive apex speeds delivered at 60fps to your handlebar display or phone mount without visual drag.',
icon: 'dashboard_customize',
},
{
title: 'Ride Intelligence & Session Replay',
description:
'Multi-layer track analysis with sector split times, deceleration zones, elevation profiles, and 3D GPS satellite trace replays after every canyon run or track session.',
icon: 'analytics',
},
{
title: 'Club Telemetry & Fleet Beacon',
description:
'Live pack radar tracking, automatic crash detection beacon with SOS emergency dispatch, and competitive leaderboards with verified telemetry data.',
icon: 'emergency',
},
{
title: 'Zero-Friction Hardware & Security',
description:
'Encrypted zero-knowledge ride logs, offline Bluetooth / CAN-bus hardware sync, and end-to-end authenticated APIs compatible with major manufacturers.',
icon: 'memory',
},
],
};
export const DEFAULT_DOWNLOAD_LINKS: DownloadLinksContent = {
android_url: 'https://motorsignal.app/builds/motorsignal-release.apk',
testflight_url: '',
play_store_url: 'https://play.google.com/store/apps/details?id=app.motorsignal',
version_name: '1.0.4',
build_number: 42,
};
export const DEFAULT_POLICY_PAGES: PolicyPagesContent = {
privacy_policy:
'MotorSignal operates under strict data minimization. Rider telemetry is private and never sold.',
terms_of_service:
'MotorSignal telemetry is for closed-course performance analysis and recreational touring.',
};
export const DEFAULT_FAQS: FaqsContent = {
items: [
{
question: 'What mounting setup is required?',
answer:
'Any rigid phone mount such as QuadLock or RAM Mount positioned in landscape or portrait.',
},
{
question: 'Does it work without cellular signal?',
answer:
'Yes, MotorSignal records 100% locally offline and syncs when connectivity returns.',
},
],
};
export const DEFAULT_SCREENSHOTS: ScreenshotsContent = {
items: [
{
title: 'Live Dashboard',
caption: 'Real-time lean gauge and cockpit telemetry',
image_url: '/screenshots/dashboard.png',
},
{
title: 'Ride Forensic Analysis',
caption: 'Interactive turn analysis with braking points',
image_url: '/screenshots/analysis.png',
},
],
};
export const DEFAULT_CHANGELOG: ChangelogContent = {
releases: [
{
version: 'v1.0.4',
release_date: '2026-09-12',
title: 'Operations Platform V1',
notes:
'Added real-time system health, telemetry diagnostics, and improved offline sync.',
},
{
version: 'v1.0.3',
release_date: '2026-09-01',
title: '20Hz Acquisition Refinements',
notes: 'Optimized sensor fusion filter latency.',
},
],
};
/**
* Server-side helper to fetch published CMS content for public pages.
* Integrates Next.js ISR tag revalidation with graceful fallback to default content.
*/
export async function getCmsDocument<T>(slug: string, fallback: T): Promise<T> {
const baseUrl = process.env.MOTORSIGNAL_API_BASE_URL ?? 'https://api.motorsignal.app';
try {
const response = await fetch(`${baseUrl}/api/v1/cms/documents/${encodeURIComponent(slug)}`, {
method: 'GET',
headers: {
accept: 'application/json',
},
next: { revalidate: 60, tags: ['cms', `cms-${slug}`] },
});
if (!response.ok) {
return fallback;
}
const data = await response.json();
if (data && typeof data === 'object' && data.published) {
return {
...fallback,
...data.published,
};
}
return fallback;
} catch {
return fallback;
}
}