Files
AyrisAIandClaude Sonnet 5 1b8cfeda95 feat: harden admin security, add AI trip planner, map view, and SEO/notification improvements
Security:
- requireAdmin() session check added to every admin-only server action
  (previously relied only on middleware path matching, which Next.js
  Server Actions don't reliably respect)
- Real Prisma + bcrypt admin auth, replacing hardcoded credentials; split
  into an Edge-safe auth.config.ts (used by proxy.ts) and the full
  Prisma-backed auth.ts (route handler, server actions, server components)
- Removed hardcoded fallback secret on the Instagram sync cron endpoint
- Honeypot field + per-IP rate limiting on contact/business-submission
  forms and the analytics events endpoint

Features:
- AI trip planner (/plan-olustur, /plan/[id]) backed by DeepSeek, grounded
  to only recommend isLocalApproved listings, with a deterministic
  link-injection fallback for anything the model doesn't format as markdown
- Interactive Leaflet/OpenStreetMap view on category listing pages
- Telegram notifications for new contact messages and business submissions

SEO:
- Brand-consistent favicon/apple-icon/PWA icons and default Open Graph/
  Twitter share images, generated via next/og (replacing default Next.js
  placeholders)
- BreadcrumbList structured data on category and listing detail pages
- Fixed two remaining raw <img> tags to use next/image

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-24 00:01:06 +03:00

167 lines
5.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { mockDb } from '../../lib/mockDb';
import type { Metadata } from "next";
import { Unbounded, Golos_Text, IBM_Plex_Mono } from "next/font/google";
import { NextIntlClientProvider } from 'next-intl';
import { getMessages, setRequestLocale } from 'next-intl/server';
import { notFound } from 'next/navigation';
import { routing } from '@/i18n/routing';
import { headers } from 'next/headers';
import Script from 'next/script';
import Navbar from '@/components/Navbar';
import Footer from '@/components/Footer';
import { SITE_URL, buildAlternates, ogLocale } from '@/lib/seo';
import "../globals.css";
const unbounded = Unbounded({
variable: "--font-unbounded",
subsets: ["latin", "cyrillic"],
weight: ["400", "600", "800"],
});
const golosText = Golos_Text({
variable: "--font-golos",
subsets: ["latin", "cyrillic"],
weight: ["400", "500", "600"],
});
const ibmPlexMono = IBM_Plex_Mono({
variable: "--font-mono",
subsets: ["latin", "cyrillic"],
weight: ["400", "500"],
});
export function generateStaticParams() {
return routing.locales.map((locale) => ({ locale }));
}
export async function generateMetadata({
params
}: {
params: Promise<{ locale: string }>
}): Promise<Metadata> {
const { locale } = await params
const headersList = await headers();
const pathname = headersList.get('x-pathname') || `/${locale}`;
const title =
locale === 'en'
? 'Marmaris Local — Local Guide, Not the Tourist Trail'
: locale === 'ru'
? 'Marmaris Local — Местный гид по Мармарису'
: 'Marmaris Local — Yerel Rehber';
const description =
locale === 'en'
? "Marmaris' best local spots — restaurants, apart hotels and businesses, curated and locally approved."
: locale === 'ru'
? 'Лучшие места Мармариса — рестораны, апарт-отели и заведения, проверенные местными жителями.'
: "Marmaris'in en iyi yerel mekanları, restoranları ve saklı apart otelleri.";
return {
title,
description,
metadataBase: new URL(SITE_URL),
manifest: '/manifest.json',
alternates: buildAlternates(pathname),
openGraph: {
title,
description,
url: `${SITE_URL}${pathname}`,
siteName: 'Marmaris Local',
locale: ogLocale(locale),
type: 'website',
},
twitter: {
card: 'summary_large_image',
title,
description,
},
};
}
export default async function RootLayout({
children,
params
}: Readonly<{
children: React.ReactNode;
params: Promise<{ locale: string }>;
}>) {
const { locale } = await params;
if (!routing.locales.includes(locale as any)) {
notFound();
}
setRequestLocale(locale);
const messages = await getMessages();
const headersList = await headers();
const pathname = headersList.get('x-pathname') || '';
const hideNavbarFooter = pathname.includes('/admin') || pathname.includes('/login') || pathname.includes('/widget');
const categories = await mockDb.getCategories();
const websiteLd = {
'@context': 'https://schema.org',
'@type': 'WebSite',
name: 'Marmaris Local',
url: SITE_URL,
potentialAction: {
'@type': 'SearchAction',
target: `${SITE_URL}/${locale}/restoran?search={search_term_string}`,
'query-input': 'required name=search_term_string',
},
};
const organizationLd = {
'@context': 'https://schema.org',
'@type': 'Organization',
name: 'Marmaris Local',
url: SITE_URL,
logo: `${SITE_URL}/${locale}/opengraph-image`,
description: 'Marmaris curated local guide and verified places directory.',
};
return (
<html
lang={locale}
className={`${unbounded.variable} ${golosText.variable} ${ibmPlexMono.variable} h-full antialiased`}
>
<body className="min-h-full flex flex-col font-sans" suppressHydrationWarning>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(websiteLd) }}
/>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(organizationLd) }}
/>
{/* VPS Panel Analytics */}
<Script
src="https://panel.ayris.tech/api/analytics/script"
data-domain="marmarislocal.com"
strategy="afterInteractive"
/>
{/* Google Analytics GA4 */}
<Script
src="https://www.googletagmanager.com/gtag/js?id=G-LB86GJKBG0"
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-LB86GJKBG0');
`}
</Script>
<NextIntlClientProvider messages={messages}>
{!hideNavbarFooter && <Navbar categories={categories} />}
{children}
{!hideNavbarFooter && <Footer />}
</NextIntlClientProvider>
</body>
</html>
);
}