cleanup
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { Resend } from 'resend';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { name, email, message, locale } = body;
|
||||
|
||||
// Validate required fields
|
||||
if (!name || !email || !message) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Missing required fields' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Validate email format
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (!emailRegex.test(email)) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Invalid email format' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Check if Resend API key is configured
|
||||
if (!process.env.RESEND_API_KEY) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Email service not configured' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||
|
||||
// Send email via Resend
|
||||
const { data, error } = await resend.emails.send({
|
||||
from: 'KLZ Cables <contact@klz-cables.com>',
|
||||
to: ['info@klz-cables.com'],
|
||||
subject: locale === 'de' ? 'Neue Kontaktanfrage' : 'New Contact Inquiry',
|
||||
html: `
|
||||
<h2>${locale === 'de' ? 'Neue Kontaktanfrage' : 'New Contact Inquiry'}</h2>
|
||||
<p><strong>${locale === 'de' ? 'Name' : 'Name'}:</strong> ${name}</p>
|
||||
<p><strong>${locale === 'de' ? 'E-Mail' : 'Email'}:</strong> ${email}</p>
|
||||
<p><strong>${locale === 'de' ? 'Nachricht' : 'Message'}:</strong></p>
|
||||
<p>${message}</p>
|
||||
<hr>
|
||||
<p><small>${locale === 'de' ? 'Gesendet über' : 'Sent via'} KLZ Cables Website</small></p>
|
||||
`,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('Resend error:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to send email' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, data },
|
||||
{ status: 200 }
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Contact API error:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Internal server error' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import type { Metadata } from 'next';
|
||||
import Link from 'next/link';
|
||||
import { getPostBySlug, getPostsByLocale, getMediaById, getSiteInfo } from '@/lib/data';
|
||||
import { getLocalizedPath } from '@/lib/i18n';
|
||||
import { t } from '@/lib/i18n';
|
||||
import { SEO } from '@/components/SEO';
|
||||
import { LocaleSwitcher } from '@/components/LocaleSwitcher';
|
||||
import { ContentRenderer } from '@/components/content/ContentRenderer';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
slug: string;
|
||||
locale?: string;
|
||||
};
|
||||
}
|
||||
|
||||
function RelatedPosts({ currentSlug, locale }: { currentSlug: string; locale: 'en' | 'de' }) {
|
||||
const allPosts = getPostsByLocale(locale);
|
||||
const currentPost = allPosts.find((p: any) => p.slug === currentSlug);
|
||||
|
||||
if (!currentPost) return null;
|
||||
|
||||
// Get recent posts (excluding current)
|
||||
const relatedPosts = allPosts
|
||||
.filter((p: any) => p.slug !== currentSlug)
|
||||
.slice(0, 3);
|
||||
|
||||
if (relatedPosts.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div className="mt-16 border-t border-gray-200 pt-12">
|
||||
<h2 className="text-2xl font-bold text-gray-900 mb-6">
|
||||
{t('blog.relatedPosts', locale as 'en' | 'de')}
|
||||
</h2>
|
||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
{relatedPosts.map((post: any) => (
|
||||
<Link
|
||||
key={post.slug}
|
||||
href={getLocalizedPath(`/blog/${post.slug}`, locale as 'en' | 'de')}
|
||||
className="group block bg-white rounded-lg border border-gray-200 overflow-hidden hover:shadow-md transition-all"
|
||||
>
|
||||
{post.featuredImage && (() => {
|
||||
const media = getMediaById(post.featuredImage);
|
||||
return media ? (
|
||||
<div className="h-40 bg-gray-100 overflow-hidden">
|
||||
<img
|
||||
src={media.localPath}
|
||||
alt={post.title}
|
||||
className="h-full w-full object-cover group-hover:scale-105 transition-transform duration-200"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
) : null;
|
||||
})()}
|
||||
<div className="p-4">
|
||||
<h3 className="font-semibold text-gray-900 group-hover:text-blue-600 transition-colors mb-2 line-clamp-2">
|
||||
{post.title}
|
||||
</h3>
|
||||
<div className="text-sm text-gray-600 line-clamp-2 mb-2">
|
||||
<ContentRenderer content={post.excerptHtml} />
|
||||
</div>
|
||||
<span className="text-xs text-blue-600 font-medium">
|
||||
{t('blog.readMore', locale as 'en' | 'de')} →
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const locale = (params.locale as string) || 'en';
|
||||
const post = getPostBySlug(params.slug, locale as 'en' | 'de');
|
||||
|
||||
if (!post) {
|
||||
return {
|
||||
title: 'Post not found',
|
||||
};
|
||||
}
|
||||
|
||||
const site = getSiteInfo();
|
||||
|
||||
// Get featured image URL if available
|
||||
let featuredImageUrl: string | undefined;
|
||||
if (post.featuredImage) {
|
||||
const media = getMediaById(post.featuredImage);
|
||||
if (media) {
|
||||
featuredImageUrl = media.localPath;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
title: `${post.title} | ${site.title}`,
|
||||
description: post.excerptHtml || undefined,
|
||||
alternates: {
|
||||
canonical: getLocalizedPath(`/blog/${post.slug}`, locale as 'en' | 'de'),
|
||||
languages: {
|
||||
'en': `/en/blog/${post.slug}`,
|
||||
'de': `/de/blog/${post.slug}`,
|
||||
},
|
||||
},
|
||||
openGraph: {
|
||||
title: post.title,
|
||||
description: post.excerptHtml || undefined,
|
||||
type: 'article',
|
||||
locale,
|
||||
publishedTime: post.datePublished,
|
||||
modifiedTime: post.updatedAt,
|
||||
...(featuredImageUrl && {
|
||||
images: [{ url: featuredImageUrl, alt: post.title }],
|
||||
}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const postsEN = getPostsByLocale('en');
|
||||
const postsDE = getPostsByLocale('de');
|
||||
|
||||
const enParams = postsEN.map((post: any) => ({
|
||||
slug: post.slug,
|
||||
locale: 'en',
|
||||
}));
|
||||
|
||||
const deParams = postsDE.map((post: any) => ({
|
||||
slug: post.slug,
|
||||
locale: 'de',
|
||||
}));
|
||||
|
||||
return [...enParams, ...deParams];
|
||||
}
|
||||
|
||||
export default async function BlogDetailPage({ params }: PageProps) {
|
||||
const locale = (params.locale as string) || 'en';
|
||||
const post = getPostBySlug(params.slug, locale as 'en' | 'de');
|
||||
|
||||
if (!post) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Content is already processed during data export
|
||||
|
||||
return (
|
||||
<>
|
||||
<SEO
|
||||
title={post.title}
|
||||
description={post.excerptHtml}
|
||||
locale={locale as 'en' | 'de'}
|
||||
path={`/blog/${post.slug}`}
|
||||
type="article"
|
||||
publishedTime={post.datePublished}
|
||||
modifiedTime={post.updatedAt}
|
||||
images={post.featuredImage ? [getMediaById(post.featuredImage)?.localPath].filter(Boolean) : undefined}
|
||||
/>
|
||||
|
||||
<article className="bg-white py-12 sm:py-20">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{/* Back to blog link */}
|
||||
<div className="mb-8">
|
||||
<Link
|
||||
href={getLocalizedPath('/blog', locale as 'en' | 'de')}
|
||||
className="inline-flex items-center text-sm text-gray-600 hover:text-gray-900 transition-colors"
|
||||
>
|
||||
<svg className="mr-2 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
{t('blog.backToBlog', locale as 'en' | 'de')}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Article Header */}
|
||||
<header className="mb-10">
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<time className="text-sm text-gray-500">
|
||||
{new Date(post.datePublished).toLocaleDateString(locale as 'en' | 'de', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
})}
|
||||
</time>
|
||||
</div>
|
||||
|
||||
<h1 className="text-4xl sm:text-5xl font-bold text-gray-900 mb-6 leading-tight">
|
||||
{post.title}
|
||||
</h1>
|
||||
|
||||
{post.excerptHtml && (
|
||||
<p className="text-xl text-gray-600 leading-relaxed">
|
||||
<ContentRenderer content={post.excerptHtml} />
|
||||
</p>
|
||||
)}
|
||||
</header>
|
||||
|
||||
{/* Featured Image */}
|
||||
{post.featuredImage && (() => {
|
||||
const media = getMediaById(post.featuredImage);
|
||||
return media ? (
|
||||
<div className="mb-12 rounded-2xl overflow-hidden bg-gray-100">
|
||||
<img
|
||||
src={media.localPath}
|
||||
alt={post.title}
|
||||
className="w-full h-auto object-cover"
|
||||
loading="eager"
|
||||
/>
|
||||
</div>
|
||||
) : null;
|
||||
})()}
|
||||
|
||||
{/* Article Content */}
|
||||
<div className="mb-12">
|
||||
<ContentRenderer
|
||||
content={post.contentHtml}
|
||||
className="prose prose-lg prose-blue"
|
||||
parsePatterns={true}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Article Footer */}
|
||||
<footer className="border-t border-gray-200 pt-8 mt-12">
|
||||
<div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
||||
<div className="flex gap-4">
|
||||
<Link
|
||||
href={getLocalizedPath('/blog', locale as 'en' | 'de')}
|
||||
className="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
{t('blog.backToList', locale as 'en' | 'de')}
|
||||
</Link>
|
||||
<Link
|
||||
href={getLocalizedPath('/contact', locale as 'en' | 'de')}
|
||||
className="inline-flex items-center px-4 py-2 border border-transparent rounded-md text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
{t('nav.contact', locale as 'en' | 'de')}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
{/* Related Posts */}
|
||||
<RelatedPosts currentSlug={params.slug} locale={locale as 'en' | 'de'} />
|
||||
</div>
|
||||
</article>
|
||||
|
||||
{/* Locale Switcher */}
|
||||
<div className="bg-gray-50 py-8">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
|
||||
<LocaleSwitcher />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,261 +0,0 @@
|
||||
import { Metadata } from 'next';
|
||||
import Link from 'next/link';
|
||||
import { getPostsByLocale, getCategoriesByLocale, getMediaById } from '@/lib/data';
|
||||
import { getSiteInfo, t, getLocalizedPath } from '@/lib/i18n';
|
||||
import { SEO } from '@/components/SEO';
|
||||
import { LocaleSwitcher } from '@/components/LocaleSwitcher';
|
||||
import { ContentRenderer } from '@/components/content/ContentRenderer';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
locale?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
return [
|
||||
{ locale: 'en' },
|
||||
{ locale: 'de' },
|
||||
];
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const locale = (params?.locale as string) || 'en';
|
||||
const site = getSiteInfo();
|
||||
const title = t('blog.title', locale as 'en' | 'de');
|
||||
const description = t('blog.description', locale as 'en' | 'de');
|
||||
|
||||
return {
|
||||
title: `${title} | ${site.title}`,
|
||||
description,
|
||||
alternates: {
|
||||
canonical: getLocalizedPath('/blog', locale as 'en' | 'de'),
|
||||
languages: {
|
||||
'en': '/en/blog',
|
||||
'de': '/de/blog',
|
||||
},
|
||||
},
|
||||
openGraph: {
|
||||
title: `${title} | ${site.title}`,
|
||||
description,
|
||||
type: 'website',
|
||||
locale,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default async function BlogPage({ params }: PageProps) {
|
||||
const locale = (params?.locale as string) || 'en';
|
||||
const posts = getPostsByLocale(locale as 'en' | 'de');
|
||||
const categories = getCategoriesByLocale(locale as 'en' | 'de');
|
||||
|
||||
const title = t('blog.title', locale as 'en' | 'de');
|
||||
const description = t('blog.description', locale as 'en' | 'de');
|
||||
|
||||
// Get featured posts (first 3)
|
||||
const featuredPosts = posts.slice(0, 3);
|
||||
// Get remaining posts
|
||||
const remainingPosts = posts.slice(3);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SEO
|
||||
title={title}
|
||||
description={description}
|
||||
locale={locale as 'en' | 'de'}
|
||||
path="/blog"
|
||||
/>
|
||||
|
||||
<div className="bg-white py-24 sm:py-32">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="max-w-2xl">
|
||||
<h1 className="text-4xl font-bold tracking-tight text-gray-900 sm:text-5xl mb-6">
|
||||
{title}
|
||||
</h1>
|
||||
<p className="text-xl text-gray-600 mb-8">
|
||||
{description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Categories */}
|
||||
{categories.length > 0 && (
|
||||
<div className="mb-12">
|
||||
<h2 className="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-4">
|
||||
{t('blog.categories', locale as 'en' | 'de')}
|
||||
</h2>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{categories.map((category) => (
|
||||
<Link
|
||||
key={category.slug}
|
||||
href={getLocalizedPath(`/blog/category/${category.slug}`, locale as 'en' | 'de')}
|
||||
className="inline-flex items-center px-3 py-1.5 rounded-full text-sm font-medium bg-blue-50 text-blue-700 hover:bg-blue-100 transition-colors"
|
||||
>
|
||||
{category.name}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Featured Posts */}
|
||||
{featuredPosts.length > 0 && (
|
||||
<div className="mb-16">
|
||||
<h2 className="text-2xl font-bold text-gray-900 mb-6">
|
||||
{t('blog.featured', locale as 'en' | 'de')}
|
||||
</h2>
|
||||
<div className="grid gap-8 md:grid-cols-2 lg:grid-cols-3">
|
||||
{featuredPosts.map((post) => (
|
||||
<article
|
||||
key={post.slug}
|
||||
className="flex flex-col bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden hover:shadow-md transition-shadow"
|
||||
>
|
||||
{post.featuredImage && (() => {
|
||||
const media = getMediaById(post.featuredImage);
|
||||
return media ? (
|
||||
<div className="h-48 overflow-hidden bg-gray-100">
|
||||
<img
|
||||
src={media.localPath}
|
||||
alt={post.title}
|
||||
className="h-full w-full object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
) : null;
|
||||
})()}
|
||||
<div className="flex-1 p-6">
|
||||
<div className="flex items-center gap-2 mb-3">
|
||||
<time className="text-xs text-gray-500">
|
||||
{new Date(post.datePublished).toLocaleDateString(locale, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
})}
|
||||
</time>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-gray-900 mb-2">
|
||||
<Link
|
||||
href={getLocalizedPath(`/blog/${post.slug}`, locale as 'en' | 'de')}
|
||||
className="hover:text-blue-600 transition-colors"
|
||||
>
|
||||
{post.title}
|
||||
</Link>
|
||||
</h3>
|
||||
<div className="text-gray-600 line-clamp-3 text-sm mb-4">
|
||||
<ContentRenderer
|
||||
content={post.excerptHtml}
|
||||
className="text-gray-600 line-clamp-3 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<Link
|
||||
href={getLocalizedPath(`/blog/${post.slug}`, locale as 'en' | 'de')}
|
||||
className="inline-flex items-center text-sm font-medium text-blue-600 hover:text-blue-700"
|
||||
>
|
||||
{t('blog.readMore', locale as 'en' | 'de')}
|
||||
<svg className="ml-1 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</Link>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* All Posts */}
|
||||
{remainingPosts.length > 0 && (
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold text-gray-900 mb-6">
|
||||
{t('blog.allPosts', locale as 'en' | 'de')}
|
||||
</h2>
|
||||
<div className="space-y-8">
|
||||
{remainingPosts.map((post) => (
|
||||
<article
|
||||
key={post.slug}
|
||||
className="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden hover:shadow-md transition-shadow"
|
||||
>
|
||||
<div className="p-6">
|
||||
<div className="flex items-center gap-2 mb-3">
|
||||
<time className="text-xs text-gray-500">
|
||||
{new Date(post.datePublished).toLocaleDateString(locale, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
})}
|
||||
</time>
|
||||
</div>
|
||||
<div className="flex gap-6">
|
||||
{post.featuredImage && (() => {
|
||||
const media = getMediaById(post.featuredImage);
|
||||
return media ? (
|
||||
<div className="w-32 h-32 flex-shrink-0 bg-gray-100 rounded-lg overflow-hidden">
|
||||
<img
|
||||
src={media.localPath}
|
||||
alt={post.title}
|
||||
className="h-full w-full object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
) : null;
|
||||
})()}
|
||||
<div className="flex-1">
|
||||
<h3 className="text-xl font-semibold text-gray-900 mb-2">
|
||||
<Link
|
||||
href={getLocalizedPath(`/blog/${post.slug}`, locale as 'en' | 'de')}
|
||||
className="hover:text-blue-600 transition-colors"
|
||||
>
|
||||
{post.title}
|
||||
</Link>
|
||||
</h3>
|
||||
<div className="text-gray-600 mb-3">
|
||||
<ContentRenderer
|
||||
content={post.excerptHtml}
|
||||
className="text-gray-600 mb-3"
|
||||
/>
|
||||
</div>
|
||||
<Link
|
||||
href={getLocalizedPath(`/blog/${post.slug}`, locale as 'en' | 'de')}
|
||||
className="inline-flex items-center text-sm font-medium text-blue-600 hover:text-blue-700"
|
||||
>
|
||||
{t('blog.readMore', locale as 'en' | 'de')}
|
||||
<svg className="ml-1 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Empty State */}
|
||||
{posts.length === 0 && (
|
||||
<div className="text-center py-16">
|
||||
<div className="inline-flex items-center justify-center w-16 h-16 rounded-full bg-gray-100 mb-4">
|
||||
<svg className="w-8 h-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
||||
</svg>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-gray-900 mb-2">
|
||||
{t('blog.noPosts', locale as 'en' | 'de')}
|
||||
</h3>
|
||||
<p className="text-gray-600">
|
||||
{t('blog.noPostsDescription', locale as 'en' | 'de')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Locale Switcher */}
|
||||
<div className="bg-gray-50 py-8">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
|
||||
<LocaleSwitcher />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import { getPageBySlug, getAllPages, getMediaById } from '@/lib/data';
|
||||
import { Metadata } from 'next';
|
||||
import { SEO } from '@/components/SEO';
|
||||
import { ContentRenderer } from '@/components/content/ContentRenderer';
|
||||
import { Breadcrumbs } from '@/components/content/Breadcrumbs';
|
||||
import { Hero } from '@/components/content/Hero';
|
||||
import { ContactForm } from '@/components/ContactForm';
|
||||
import { ResponsiveSection, ResponsiveWrapper } from '@/components/layout/ResponsiveWrapper';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const pages = await getAllPages();
|
||||
// Filter for contact pages only
|
||||
const contactPages = pages.filter(p => p.slug === 'contact' || p.slug === 'kontakt');
|
||||
return contactPages.map((page) => ({
|
||||
locale: page.locale,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const { locale } = params;
|
||||
const slug = locale === 'de' ? 'kontakt' : 'contact';
|
||||
|
||||
const page = await getPageBySlug(slug, locale);
|
||||
|
||||
if (!page) {
|
||||
return {
|
||||
title: 'Contact Not Found',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: page.title,
|
||||
description: page.excerptHtml || '',
|
||||
alternates: {
|
||||
languages: {
|
||||
de: '/de/kontakt',
|
||||
en: '/en/contact',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default async function ContactPage({ params }: PageProps) {
|
||||
const { locale } = params;
|
||||
const slug = locale === 'de' ? 'kontakt' : 'contact';
|
||||
|
||||
const page = await getPageBySlug(slug, locale);
|
||||
|
||||
if (!page) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Get featured image if available
|
||||
const featuredImage = page.featuredImage ? getMediaById(page.featuredImage) : null;
|
||||
|
||||
// Content is already processed during data export
|
||||
const contentToDisplay = page.contentHtml && page.contentHtml.trim() !== ''
|
||||
? page.contentHtml
|
||||
: page.excerptHtml;
|
||||
|
||||
// Breadcrumb items
|
||||
const breadcrumbItems = [
|
||||
{ label: locale === 'de' ? 'Kontakt' : 'Contact' }
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<SEO
|
||||
title={page.title}
|
||||
description={page.excerptHtml || ''}
|
||||
/>
|
||||
|
||||
{/* Breadcrumbs */}
|
||||
<Breadcrumbs
|
||||
items={breadcrumbItems}
|
||||
homeLabel={locale === 'de' ? 'Startseite' : 'Home'}
|
||||
homeHref={`/${locale}`}
|
||||
/>
|
||||
|
||||
{/* Hero Section with Featured Image */}
|
||||
{featuredImage && (
|
||||
<Hero
|
||||
title={page.title}
|
||||
subtitle={page.excerptHtml ? page.excerptHtml.replace(/<[^>]*>/g, '') : undefined}
|
||||
backgroundImage={featuredImage.localPath}
|
||||
backgroundAlt={page.title}
|
||||
height="md"
|
||||
variant="dark"
|
||||
overlay={true}
|
||||
overlayOpacity={0.5}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Main Content */}
|
||||
<ResponsiveSection padding="responsive" maxWidth="4xl">
|
||||
{!featuredImage && (
|
||||
<ResponsiveWrapper stackOnMobile={true} centerOnMobile={true} className="mb-8">
|
||||
<h1 className="text-3xl sm:text-4xl font-bold text-gray-900 mb-4">
|
||||
{page.title}
|
||||
</h1>
|
||||
{page.excerptHtml && (
|
||||
<ContentRenderer
|
||||
content={page.excerptHtml}
|
||||
className="text-lg sm:text-xl text-gray-600 leading-relaxed"
|
||||
/>
|
||||
)}
|
||||
</ResponsiveWrapper>
|
||||
)}
|
||||
|
||||
{/* Content from WordPress */}
|
||||
{contentToDisplay && (
|
||||
<ResponsiveWrapper className="bg-white rounded-lg shadow-sm p-6 sm:p-8 mb-12" container={true} maxWidth="full">
|
||||
<ContentRenderer
|
||||
content={contentToDisplay}
|
||||
className="prose prose-lg max-w-none"
|
||||
/>
|
||||
</ResponsiveWrapper>
|
||||
)}
|
||||
|
||||
{/* Contact Form */}
|
||||
<ResponsiveWrapper className="bg-gray-50 rounded-lg p-6 sm:p-8" container={true} maxWidth="full">
|
||||
<ContactForm />
|
||||
</ResponsiveWrapper>
|
||||
</ResponsiveSection>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
import { ContentRenderer } from '@/components/content/ContentRenderer';
|
||||
import { Section } from '@/components/content/Section';
|
||||
import { Container } from '@/components/ui/Container';
|
||||
|
||||
// Test content with various WordPress shortcodes and images
|
||||
const testContent = `
|
||||
<div class="vc-row" style="background-color: #f8f9fa; padding-top: 4rem; padding-bottom: 4rem;">
|
||||
<div class="vc-column">
|
||||
<div class="vc-column-text">
|
||||
<h2>WordPress Shortcode Test</h2>
|
||||
<p>This page demonstrates the enhanced ContentRenderer handling various WordPress shortcodes and image formats.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vc-row">
|
||||
<div class="vc-column" style="width: 50%;">
|
||||
<div class="vc-column-text">
|
||||
<h3>Left Column</h3>
|
||||
<p>This column uses vc_col-md-6 shortcode converted to Tailwind classes.</p>
|
||||
<a href="/contact" class="btn btn-primary">Contact Button</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vc-column" style="width: 50%;">
|
||||
<div class="vc-column-text">
|
||||
<h3>Right Column</h3>
|
||||
<p>Content in the right column with proper spacing and styling.</p>
|
||||
<img data-wp-image-id="6517" alt="Medium Voltage Cable" class="alignnone size-medium" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vc-row" style="background-image: url(/media/45524-5.webp); background-size: cover; background-position: center;">
|
||||
<div class="vc-column">
|
||||
<div class="vc-column-text" style="color: white; text-align: center;">
|
||||
<h2 style="color: white;">Background Image Section</h2>
|
||||
<p style="color: white;">This section has a background image from WordPress media library.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vc-row">
|
||||
<div class="vc-column">
|
||||
<div class="vc-column-text">
|
||||
<h3>Image Gallery</h3>
|
||||
<p>Multiple images with different alignments:</p>
|
||||
<img data-wp-image-id="6521" alt="Low Voltage Cable" class="alignleft size-thumbnail" style="margin-right: 1rem; margin-bottom: 1rem;" />
|
||||
<img data-wp-image-id="47052" alt="NA2XSF2X Cable" class="alignright size-thumbnail" style="margin-left: 1rem; margin-bottom: 1rem;" />
|
||||
<p>Images should display correctly with proper Next.js Image optimization and alignment.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vc-row" style="background-color: #0a0a0a; color: white; padding-top: 3rem; padding-bottom: 3rem;">
|
||||
<div class="vc-column">
|
||||
<div class="vc-column-text" style="color: white;">
|
||||
<h3 style="color: white;">Dark Section with Buttons</h3>
|
||||
<p style="color: white;">Various button styles should work correctly:</p>
|
||||
<div style="display: flex; gap: 1rem; flex-wrap: wrap;">
|
||||
<a href="#" class="btn btn-primary">Primary Button</a>
|
||||
<a href="#" class="btn btn-secondary">Secondary Button</a>
|
||||
<a href="#" class="btn btn-outline">Outline Button</a>
|
||||
<a href="#" class="btn btn-primary btn-large">Large Button</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vc-row">
|
||||
<div class="vc-column">
|
||||
<div class="vc-column-text">
|
||||
<h3>Typography Test</h3>
|
||||
<p>Regular paragraph text with <strong>bold text</strong>, <em>italic text</em>, and <a href="https://example.com">external links</a>.</p>
|
||||
<ul>
|
||||
<li>List item 1</li>
|
||||
<li>List item 2</li>
|
||||
<li>List item 3</li>
|
||||
</ul>
|
||||
<blockquote>
|
||||
<p>This is a blockquote with proper styling.</p>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vc-row" style="background-color: #e9ecef; padding-top: 2rem; padding-bottom: 2rem;">
|
||||
<div class="vc-column" style="width: 33.33%;">
|
||||
<div class="vc-column-text">
|
||||
<h4>Column 1</h4>
|
||||
<p>One-third width column.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vc-column" style="width: 33.33%;">
|
||||
<div class="vc-column-text">
|
||||
<h4>Column 2</h4>
|
||||
<p>One-third width column.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vc-column" style="width: 33.33%;">
|
||||
<div class="vc-column-text">
|
||||
<h4>Column 3</h4>
|
||||
<p>One-third width column.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vc-row">
|
||||
<div class="vc-column">
|
||||
<div class="vc-column-text">
|
||||
<h3>Direct Image References</h3>
|
||||
<p>Images referenced by ID should be converted to Next.js Image components:</p>
|
||||
<img data-wp-image-id="10797" alt="Medium Voltage Cables" class="aligncenter size-large" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const testContentWithShortcodes = `
|
||||
[vc_row bg_color="#f8f9fa" top_padding="4%" bottom_padding="4%"]
|
||||
[vc_column width="12"]
|
||||
[vc_column_text]
|
||||
<h2>Raw Shortcode Test</h2>
|
||||
<p>This content uses raw WordPress shortcodes that should be processed by html-compat.ts</p>
|
||||
[/vc_column_text]
|
||||
[/vc_column]
|
||||
[/vc_row]
|
||||
|
||||
[vc_row]
|
||||
[vc_column width="6"]
|
||||
[vc_column_text]
|
||||
<h3>Left Side</h3>
|
||||
<p>Content with [vc_btn color="primary" title="Click Here" link="#"] embedded.</p>
|
||||
[/vc_column_text]
|
||||
[/vc_column]
|
||||
[vc_column width="6"]
|
||||
[vc_column_text]
|
||||
<h3>Right Side</h3>
|
||||
<p>Another column with [vc_single_image src="6521" align="right"] embedded.</p>
|
||||
[/vc_column_text]
|
||||
[/vc_column]
|
||||
[/vc_row]
|
||||
|
||||
[vc_row bg_image="45528" top_padding="15%" bottom_padding="15%" color_overlay="#000000" overlay_strength="0.7"]
|
||||
[vc_column]
|
||||
[vc_column_text text_color="light" text_align="center"]
|
||||
<h2>Background Image with Overlay</h2>
|
||||
<p>This should show an image with dark overlay and white text.</p>
|
||||
[/vc_column_text]
|
||||
[/vc_column]
|
||||
[/vc_row]
|
||||
|
||||
[vc_row enable_gradient="true" gradient_direction="left_to_right"]
|
||||
[vc_column]
|
||||
[vc_column_text text_align="center"]
|
||||
<h3>Gradient Background</h3>
|
||||
<p>This row should have a gradient background.</p>
|
||||
[/vc_column_text]
|
||||
[/vc_column]
|
||||
[/vc_row]
|
||||
`;
|
||||
|
||||
export default function ComponentsDemoPage() {
|
||||
return (
|
||||
<Container>
|
||||
<Section>
|
||||
<div className="space-y-8">
|
||||
<div className="text-center space-y-4">
|
||||
<h1 className="text-4xl font-bold">ContentRenderer Test Page</h1>
|
||||
<p className="text-lg text-gray-600">
|
||||
Testing WordPress shortcode conversion and image handling
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-lg shadow-lg p-6">
|
||||
<h2 className="text-2xl font-bold mb-4">Processed HTML Content</h2>
|
||||
<ContentRenderer
|
||||
content={testContent}
|
||||
sanitize={true}
|
||||
processAssets={true}
|
||||
convertClasses={true}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-lg shadow-lg p-6">
|
||||
<h2 className="text-2xl font-bold mb-4">Raw Shortcode Content</h2>
|
||||
<ContentRenderer
|
||||
content={testContentWithShortcodes}
|
||||
sanitize={true}
|
||||
processAssets={true}
|
||||
convertClasses={true}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="bg-blue-50 rounded-lg p-6">
|
||||
<h3 className="text-xl font-bold mb-3">What This Tests:</h3>
|
||||
<ul className="list-disc list-inside space-y-2">
|
||||
<li>✅ [vc_row] → flex containers with background support</li>
|
||||
<li>✅ [vc_column] → responsive width classes</li>
|
||||
<li>✅ [vc_column_text] → prose styling</li>
|
||||
<li>✅ [vc_btn] → styled buttons</li>
|
||||
<li>✅ [vc_single_image] → Next.js Image components</li>
|
||||
<li>✅ Background images from WordPress IDs</li>
|
||||
<li>✅ Color overlays and gradients</li>
|
||||
<li>✅ Image alignment and sizing</li>
|
||||
<li>✅ URL replacement from data layer</li>
|
||||
<li>✅ Inline styles and attributes</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
import { Metadata } from 'next';
|
||||
import { Container } from '@/components/ui/Container';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { Card, CardHeader, CardBody, CardFooter } from '@/components/ui/Card';
|
||||
import { Grid, GridItem } from '@/components/ui/Grid';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Layout Example | KLZ Cables',
|
||||
description: 'Example page demonstrating the new layout components',
|
||||
};
|
||||
|
||||
export default function ExamplePage() {
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
{/* Hero Section */}
|
||||
<section className="bg-gradient-to-r from-blue-600 to-blue-800 text-white py-16 rounded-xl">
|
||||
<Container maxWidth="4xl" padding="lg" className="text-center">
|
||||
<h1 className="text-4xl md:text-5xl font-bold mb-4">
|
||||
Layout Components Demo
|
||||
</h1>
|
||||
<p className="text-xl text-blue-100 mb-6">
|
||||
Showcasing the new Header, Footer, Layout, and MobileMenu components
|
||||
</p>
|
||||
<div className="flex gap-3 justify-center flex-wrap">
|
||||
<Button variant="primary" size="lg">
|
||||
Primary Action
|
||||
</Button>
|
||||
<Button variant="outline" size="lg">
|
||||
Secondary Action
|
||||
</Button>
|
||||
</div>
|
||||
</Container>
|
||||
</section>
|
||||
|
||||
{/* Feature Cards */}
|
||||
<section>
|
||||
<Container maxWidth="6xl" padding="md">
|
||||
<h2 className="text-3xl font-bold mb-6 text-center">Key Features</h2>
|
||||
<Grid cols={3} gap="lg">
|
||||
<GridItem>
|
||||
<Card variant="elevated">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Badge variant="primary">New</Badge>
|
||||
<h3 className="text-xl font-semibold">Responsive Header</h3>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<p className="text-gray-600">
|
||||
Sticky header with mobile hamburger menu, locale switcher, and contact CTA.
|
||||
Fully responsive with smooth animations.
|
||||
</p>
|
||||
</CardBody>
|
||||
<CardFooter>
|
||||
<Button variant="ghost" size="sm">Learn More</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</GridItem>
|
||||
|
||||
<GridItem>
|
||||
<Card variant="elevated">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Badge variant="secondary">Updated</Badge>
|
||||
<h3 className="text-xl font-semibold">Smart Footer</h3>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<p className="text-gray-600">
|
||||
4-column responsive layout with company info, quick links,
|
||||
product categories, and contact details.
|
||||
</p>
|
||||
</CardBody>
|
||||
<CardFooter>
|
||||
<Button variant="ghost" size="sm">View Details</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</GridItem>
|
||||
|
||||
<GridItem>
|
||||
<Card variant="elevated">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Badge variant="success">Enhanced</Badge>
|
||||
<h3 className="text-xl font-semibold">Mobile Menu</h3>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<p className="text-gray-600">
|
||||
Slide-out drawer with smooth animations, full navigation,
|
||||
language switcher, and contact information.
|
||||
</p>
|
||||
</CardBody>
|
||||
<CardFooter>
|
||||
<Button variant="ghost" size="sm">Try It</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</GridItem>
|
||||
</Grid>
|
||||
</Container>
|
||||
</section>
|
||||
|
||||
{/* Component Showcase */}
|
||||
<section className="bg-gray-50 py-12">
|
||||
<Container maxWidth="6xl" padding="md">
|
||||
<h2 className="text-3xl font-bold mb-6 text-center">UI Components</h2>
|
||||
<div className="space-y-6">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-xl font-semibold">Buttons</h3>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button variant="primary">Primary</Button>
|
||||
<Button variant="secondary">Secondary</Button>
|
||||
<Button variant="outline">Outline</Button>
|
||||
<Button variant="ghost">Ghost</Button>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2 mt-3">
|
||||
<Button variant="primary" size="sm">Small</Button>
|
||||
<Button variant="primary" size="md">Medium</Button>
|
||||
<Button variant="primary" size="lg">Large</Button>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-xl font-semibold">Badges</h3>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Badge variant="primary">Primary</Badge>
|
||||
<Badge variant="secondary">Secondary</Badge>
|
||||
<Badge variant="success">Success</Badge>
|
||||
<Badge variant="warning">Warning</Badge>
|
||||
<Badge variant="error">Error</Badge>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-xl font-semibold">Container & Grid</h3>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<p className="text-gray-600 mb-4">
|
||||
The Container component provides responsive max-width and padding,
|
||||
while Grid offers flexible column layouts.
|
||||
</p>
|
||||
<Grid cols={4} gap="md">
|
||||
<div className="bg-blue-100 p-4 rounded text-center">1</div>
|
||||
<div className="bg-blue-100 p-4 rounded text-center">2</div>
|
||||
<div className="bg-blue-100 p-4 rounded text-center">3</div>
|
||||
<div className="bg-blue-100 p-4 rounded text-center">4</div>
|
||||
</Grid>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</Container>
|
||||
</section>
|
||||
|
||||
{/* Integration Example */}
|
||||
<section>
|
||||
<Container maxWidth="6xl" padding="md">
|
||||
<h2 className="text-3xl font-bold mb-6 text-center">Integration Example</h2>
|
||||
<Card variant="elevated">
|
||||
<CardHeader>
|
||||
<h3 className="text-xl font-semibold">How to Use in Your Pages</h3>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<pre className="bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto text-sm">
|
||||
<code>{`// app/[locale]/my-page/page.tsx
|
||||
import { Metadata } from 'next';
|
||||
import { Container } from '@/components/ui/Container';
|
||||
import { Layout } from '@/components/layout/Layout';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'My Page | KLZ Cables',
|
||||
description: 'My custom page description',
|
||||
};
|
||||
|
||||
export default function MyPage({ params: { locale } }: { params: { locale: string } }) {
|
||||
return (
|
||||
<Layout locale={locale} siteName="KLZ Cables">
|
||||
<Container maxWidth="6xl" padding="md">
|
||||
<h1>My Page Content</h1>
|
||||
{/* Your content here */}
|
||||
</Container>
|
||||
</Layout>
|
||||
);
|
||||
}`}</code>
|
||||
</pre>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</Container>
|
||||
</section>
|
||||
|
||||
{/* Breadcrumb Demo */}
|
||||
<section className="bg-gray-50 py-8">
|
||||
<Container maxWidth="6xl" padding="md">
|
||||
<h2 className="text-2xl font-bold mb-4">Breadcrumb Support</h2>
|
||||
<p className="text-gray-600 mb-4">
|
||||
The Layout component supports optional breadcrumbs. Check the URL bar
|
||||
and try navigating to see the breadcrumb in action.
|
||||
</p>
|
||||
<a href="/en/example/subpage">
|
||||
<Button>Go to Example Subpage (with Breadcrumb)</Button>
|
||||
</a>
|
||||
</Container>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
import { Metadata } from 'next';
|
||||
import { Container } from '@/components/ui/Container';
|
||||
import { Layout } from '@/components/layout/Layout';
|
||||
import { Card, CardHeader, CardBody } from '@/components/ui/Card';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import Link from 'next/link';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Subpage Example | KLZ Cables',
|
||||
description: 'Example subpage demonstrating breadcrumb functionality',
|
||||
};
|
||||
|
||||
export default function Subpage({ params: { locale } }: { params: { locale: string } }) {
|
||||
// Breadcrumb configuration
|
||||
const breadcrumb = [
|
||||
{ title: 'Example', path: `/${locale}/example` },
|
||||
{ title: 'Subpage', path: `/${locale}/example/subpage` }
|
||||
];
|
||||
|
||||
return (
|
||||
<Layout
|
||||
locale={locale}
|
||||
siteName="KLZ Cables"
|
||||
breadcrumb={breadcrumb}
|
||||
>
|
||||
<Container maxWidth="6xl" padding="md">
|
||||
<div className="space-y-6">
|
||||
{/* Page Header */}
|
||||
<div className="text-center space-y-3">
|
||||
<h1 className="text-4xl font-bold text-gray-900">Subpage with Breadcrumb</h1>
|
||||
<p className="text-lg text-gray-600 max-w-2xl mx-auto">
|
||||
This page demonstrates the breadcrumb functionality in the Layout component.
|
||||
Notice the breadcrumb navigation above this content area.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<Card variant="elevated">
|
||||
<CardHeader>
|
||||
<h2 className="text-2xl font-semibold">Breadcrumb Features</h2>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<ul className="space-y-3 text-gray-700">
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-primary font-bold">✓</span>
|
||||
<span>Automatic breadcrumb generation based on current URL</span>
|
||||
</li>
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-primary font-bold">✓</span>
|
||||
<span>Clickable links for all parent pages</span>
|
||||
</li>
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-primary font-bold">✓</span>
|
||||
<span>Current page shown as non-clickable text</span>
|
||||
</li>
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-primary font-bold">✓</span>
|
||||
<span>Responsive design that works on all screen sizes</span>
|
||||
</li>
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-primary font-bold">✓</span>
|
||||
<span>Optional feature - only shown when breadcrumb prop is provided</span>
|
||||
</li>
|
||||
</ul>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
{/* Navigation */}
|
||||
<div className="flex justify-center gap-4">
|
||||
<Link href={`/${locale}/example`}>
|
||||
<Button variant="outline">← Back to Example</Button>
|
||||
</Link>
|
||||
<Link href={`/${locale}`}>
|
||||
<Button variant="primary">Home</Button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Code Example */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-xl font-semibold">How to Use Breadcrumbs</h3>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<pre className="bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto text-sm">
|
||||
<code>{`// In your page component:
|
||||
import { Layout } from '@/components/layout/Layout';
|
||||
|
||||
export default function MyPage({ params: { locale } }) {
|
||||
const breadcrumb = [
|
||||
{ title: 'Home', path: \`/\${locale}\` },
|
||||
{ title: 'Products', path: \`/\${locale}/products\` },
|
||||
{ title: 'Details', path: \`/\${locale}/products/123\` }
|
||||
];
|
||||
|
||||
return (
|
||||
<Layout
|
||||
locale={locale}
|
||||
breadcrumb={breadcrumb}
|
||||
>
|
||||
{/* Your content */}
|
||||
</Layout>
|
||||
);
|
||||
}`}</code>
|
||||
</pre>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</Container>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import type { Metadata } from 'next';
|
||||
import { Inter } from 'next/font/google';
|
||||
import '../globals.css';
|
||||
import { Layout } from '@/components/layout/Layout';
|
||||
import { CookieConsent } from '@/components/CookieConsent';
|
||||
|
||||
const inter = Inter({
|
||||
subsets: ['latin', 'latin-ext'],
|
||||
display: 'swap',
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'KLZ Cables',
|
||||
description: 'Professional cable solutions for industrial applications',
|
||||
metadataBase: new URL('https://klz-cables.com'),
|
||||
alternates: {
|
||||
canonical: '/',
|
||||
languages: {
|
||||
'en': '/en',
|
||||
'de': '/de',
|
||||
},
|
||||
},
|
||||
openGraph: {
|
||||
title: 'KLZ Cables',
|
||||
description: 'Professional cable solutions for industrial applications',
|
||||
type: 'website',
|
||||
locale: 'en',
|
||||
siteName: 'KLZ Cables',
|
||||
},
|
||||
};
|
||||
|
||||
export default function LocaleLayout({
|
||||
children,
|
||||
params: { locale },
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: { locale: string };
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Layout
|
||||
locale={locale}
|
||||
siteName="KLZ Cables"
|
||||
logo="/media/logo.svg"
|
||||
>
|
||||
{children}
|
||||
</Layout>
|
||||
<CookieConsent />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import { ContentRenderer } from '@/components/content/ContentRenderer';
|
||||
import { FeaturedImage } from '@/components/content/FeaturedImage';
|
||||
import { ResponsiveWrapper, ResponsiveSection } from '@/components/layout/ResponsiveWrapper';
|
||||
import { LocaleSwitcher } from '@/components/LocaleSwitcher';
|
||||
import { SEO } from '@/components/SEO';
|
||||
import { Container } from '@/components/ui/Container';
|
||||
import { getAllPages, getMediaById, getPageBySlug } from '@/lib/data';
|
||||
import { Metadata } from 'next';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
locale: string;
|
||||
slug?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const pages = await getAllPages();
|
||||
const params = pages.map((page) => ({
|
||||
locale: page.locale,
|
||||
slug: page.slug,
|
||||
}));
|
||||
return params;
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const { locale, slug = 'home' } = params;
|
||||
|
||||
// Map root path to actual home page slugs
|
||||
const homeSlugs: Record<string, string> = {
|
||||
'en': 'corporate-3-landing-2',
|
||||
'de': 'start'
|
||||
};
|
||||
|
||||
const actualSlug = slug === 'home' ? homeSlugs[locale] || 'home' : slug;
|
||||
const page = await getPageBySlug(actualSlug, locale);
|
||||
|
||||
if (!page) {
|
||||
return {
|
||||
title: 'Page Not Found',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: page.title,
|
||||
description: page.excerptHtml || '',
|
||||
alternates: {
|
||||
languages: {
|
||||
de: slug === 'home' ? '/de' : `/de/${slug}`,
|
||||
en: slug === 'home' ? '/en' : `/en/${slug}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default async function Page({ params }: PageProps) {
|
||||
const { locale, slug = 'home' } = params;
|
||||
|
||||
// Map root path to actual home page slugs
|
||||
const homeSlugs: Record<string, string> = {
|
||||
'en': 'corporate-3-landing-2',
|
||||
'de': 'start'
|
||||
};
|
||||
|
||||
const actualSlug = slug === 'home' ? homeSlugs[locale] || 'home' : slug;
|
||||
const page = await getPageBySlug(actualSlug, locale);
|
||||
|
||||
if (!page) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Special handling for home page vs other pages
|
||||
const isHomePage = slug === 'home' || actualSlug === 'corporate-3-landing-2' || actualSlug === 'start';
|
||||
|
||||
if (isHomePage) {
|
||||
// HOME PAGE: Render content directly without additional wrappers
|
||||
// The content already contains full vc_row structures with backgrounds
|
||||
return (
|
||||
<>
|
||||
<SEO
|
||||
title={page.title}
|
||||
description={page.excerptHtml || ''}
|
||||
/>
|
||||
|
||||
{/* Main content - full width, no containers */}
|
||||
<div className="w-full">
|
||||
<ContentRenderer
|
||||
content={page.contentHtml || page.excerptHtml || ''}
|
||||
className=""
|
||||
parsePatterns={true}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Locale switcher at bottom */}
|
||||
<ResponsiveSection padding="responsive" className="bg-gray-50">
|
||||
<Container maxWidth="6xl" centered={true} padding="none">
|
||||
<LocaleSwitcher />
|
||||
</Container>
|
||||
</ResponsiveSection>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// STANDARD PAGES: Use the existing layout with hero and containers
|
||||
const contentToDisplay = page.contentHtml || page.excerptHtml;
|
||||
const featuredImage = page.featuredImage ? getMediaById(page.featuredImage) : null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<SEO
|
||||
title={page.title}
|
||||
description={page.excerptHtml || ''}
|
||||
/>
|
||||
|
||||
{/* Hero Section with Featured Image */}
|
||||
{featuredImage && (
|
||||
<ResponsiveWrapper className="relative bg-gray-200" padding="none">
|
||||
<FeaturedImage
|
||||
src={featuredImage.localPath}
|
||||
alt={page.title}
|
||||
size="full"
|
||||
aspectRatio="16:9"
|
||||
priority={true}
|
||||
className="opacity-90"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black bg-opacity-40"></div>
|
||||
<div className="absolute inset-0 flex items-center justify-center text-center">
|
||||
<h1 className="text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-bold text-white drop-shadow-lg px-4">
|
||||
{page.title}
|
||||
</h1>
|
||||
</div>
|
||||
</ResponsiveWrapper>
|
||||
)}
|
||||
|
||||
{/* Main Content */}
|
||||
<ResponsiveSection padding="responsive" maxWidth="4xl">
|
||||
{/* Title - only show if no featured image */}
|
||||
{!featuredImage && (
|
||||
<ResponsiveWrapper stackOnMobile={true} centerOnMobile={true} className="mb-8">
|
||||
<h1 className="text-3xl sm:text-4xl font-bold text-gray-900 mb-4">
|
||||
{page.title}
|
||||
</h1>
|
||||
</ResponsiveWrapper>
|
||||
)}
|
||||
|
||||
{/* Content with pattern parsing */}
|
||||
{contentToDisplay && (
|
||||
<ResponsiveWrapper className="bg-white rounded-lg shadow-sm p-6 sm:p-8" container={true} maxWidth="full">
|
||||
<ContentRenderer
|
||||
content={contentToDisplay}
|
||||
className="prose prose-lg max-w-none"
|
||||
parsePatterns={true}
|
||||
/>
|
||||
</ResponsiveWrapper>
|
||||
)}
|
||||
</ResponsiveSection>
|
||||
|
||||
{/* Locale Switcher */}
|
||||
<ResponsiveSection padding="responsive" className="bg-gray-50">
|
||||
<Container maxWidth="6xl" centered={true} padding="none">
|
||||
<LocaleSwitcher />
|
||||
</Container>
|
||||
</ResponsiveSection>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
import { notFound } from 'next/navigation'
|
||||
import { getAllCategories, getProductsByCategorySlugWithExcel } from '@/lib/data'
|
||||
import { ProductList } from '@/components/ProductList'
|
||||
import { Metadata } from 'next'
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
slug: string;
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const categories = getAllCategories()
|
||||
const category = categories.find(c => c.slug === params.slug && c.locale === params.locale)
|
||||
|
||||
if (!category) {
|
||||
return {
|
||||
title: 'Category not found',
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
title: category.name,
|
||||
description: category.description || `Products in ${category.name}`
|
||||
}
|
||||
}
|
||||
|
||||
export default async function ProductCategoryPage({ params }: PageProps) {
|
||||
const categories = getAllCategories()
|
||||
const category = categories.find(c => c.slug === params.slug && c.locale === params.locale)
|
||||
|
||||
if (!category) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const products = getProductsByCategorySlugWithExcel(params.slug, params.locale)
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<h1 className="text-4xl font-bold mb-8">{category.name}</h1>
|
||||
|
||||
{category.description && (
|
||||
<p className="text-gray-600 mb-8 text-lg">{category.description}</p>
|
||||
)}
|
||||
|
||||
{products.length > 0 ? (
|
||||
<ProductList products={products} locale={params.locale as 'en' | 'de'} />
|
||||
) : (
|
||||
<p className="text-gray-500">No products found in this category.</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,335 +0,0 @@
|
||||
import { Metadata } from 'next';
|
||||
import Link from 'next/link';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { getProductBySlugWithExcel, getAllProducts, getCategoriesByLocale } from '@/lib/data';
|
||||
import { getSiteInfo, t, getLocaleFromPath, getLocalizedPath } from '@/lib/i18n';
|
||||
import { SEO } from '@/components/SEO';
|
||||
import { LocaleSwitcher } from '@/components/LocaleSwitcher';
|
||||
import { ContentRenderer } from '@/components/content/ContentRenderer';
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
slug: string;
|
||||
locale?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const locale = (params.locale as string) || 'en';
|
||||
const product = getProductBySlugWithExcel(params.slug, locale as 'en' | 'de');
|
||||
|
||||
if (!product) {
|
||||
return {
|
||||
title: 'Product not found',
|
||||
};
|
||||
}
|
||||
|
||||
const site = getSiteInfo();
|
||||
|
||||
return {
|
||||
title: `${product.name} | ${site.title}`,
|
||||
description: product.shortDescriptionHtml || product.descriptionHtml.substring(0, 160) || '',
|
||||
alternates: {
|
||||
canonical: getLocalizedPath(`/product/${product.slug}`, locale as 'en' | 'de'),
|
||||
languages: {
|
||||
'en': `/en/product/${product.slug}`,
|
||||
'de': `/de/product/${product.slug}`,
|
||||
},
|
||||
},
|
||||
openGraph: {
|
||||
title: product.name,
|
||||
description: product.shortDescriptionHtml || product.descriptionHtml.substring(0, 160) || '',
|
||||
type: 'website',
|
||||
locale,
|
||||
...(product.images && product.images.length > 0 && {
|
||||
images: product.images.map(img => ({ url: img, alt: product.name })),
|
||||
}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const productsEN = getAllProducts();
|
||||
const productsDE = getAllProducts();
|
||||
|
||||
const enParams = productsEN.filter(p => p.locale === 'en').map((product) => ({
|
||||
slug: product.slug,
|
||||
locale: 'en',
|
||||
}));
|
||||
|
||||
const deParams = productsDE.filter(p => p.locale === 'de').map((product) => ({
|
||||
slug: product.slug,
|
||||
locale: 'de',
|
||||
}));
|
||||
|
||||
return [...enParams, ...deParams];
|
||||
}
|
||||
|
||||
export default async function ProductDetailPage({ params }: PageProps) {
|
||||
const locale = (params.locale as string) || 'en';
|
||||
const product = getProductBySlugWithExcel(params.slug, locale as 'en' | 'de');
|
||||
|
||||
if (!product) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Content is already processed during data export
|
||||
const processedDescription = product.descriptionHtml || '';
|
||||
const processedShortDescription = product.shortDescriptionHtml || '';
|
||||
|
||||
// Get related products (same category)
|
||||
const allProducts = getAllProducts();
|
||||
const relatedProducts = allProducts
|
||||
.filter((p: any) =>
|
||||
p.locale === locale &&
|
||||
p.slug !== product.slug &&
|
||||
p.categories?.some((cat: any) => product.categories?.some((pc: any) => pc.slug === cat.slug))
|
||||
)
|
||||
.slice(0, 4);
|
||||
|
||||
// Prepare technical data for display
|
||||
const hasExcelData = product.excelConfigurations && product.excelConfigurations.length > 0;
|
||||
const hasExcelAttributes = product.excelAttributes && product.excelAttributes.length > 0;
|
||||
|
||||
return (
|
||||
<>
|
||||
<SEO
|
||||
title={product.name}
|
||||
description={product.shortDescriptionHtml || product.descriptionHtml.substring(0, 160) || ''}
|
||||
locale={locale as 'en' | 'de'}
|
||||
path={`/product/${product.slug}`}
|
||||
type="product"
|
||||
images={product.images}
|
||||
/>
|
||||
|
||||
<div className="bg-white py-12 sm:py-20">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{/* Back to products link */}
|
||||
<div className="mb-8">
|
||||
<Link
|
||||
href={getLocalizedPath('/products', locale as 'en' | 'de')}
|
||||
className="inline-flex items-center text-sm text-gray-600 hover:text-gray-900 transition-colors"
|
||||
>
|
||||
<svg className="mr-2 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
{t('products.backToProducts', locale as 'en' | 'de')}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="lg:grid lg:grid-cols-2 lg:gap-x-12 lg:items-start">
|
||||
{/* Product Images */}
|
||||
<div className="flex flex-col-reverse">
|
||||
{product.images && product.images.length > 0 ? (
|
||||
<>
|
||||
<div className="hidden lg:grid lg:grid-cols-1 lg:gap-4 mt-4">
|
||||
{product.images.map((img: string, index: number) => (
|
||||
<div key={index} className="aspect-square overflow-hidden rounded-lg bg-gray-100">
|
||||
<img
|
||||
src={img}
|
||||
alt={`${product.name} - ${index + 1}`}
|
||||
className="h-full w-full object-cover object-center"
|
||||
loading={index === 0 ? 'eager' : 'lazy'}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="lg:hidden aspect-square overflow-hidden rounded-lg bg-gray-100 mb-4">
|
||||
<img
|
||||
src={product.images[0]}
|
||||
alt={product.name}
|
||||
className="h-full w-full object-cover object-center"
|
||||
loading="eager"
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="aspect-square overflow-hidden rounded-lg bg-gray-100 flex items-center justify-center">
|
||||
<svg className="h-24 w-24 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
||||
</svg>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Product Info */}
|
||||
<div className="mt-10 px-4 sm:px-0 sm:mt-16 lg:mt-0">
|
||||
{/* Categories */}
|
||||
{product.categories && product.categories.length > 0 && (
|
||||
<div className="flex flex-wrap gap-2 mb-4">
|
||||
{product.categories.map((cat: any) => (
|
||||
<Link
|
||||
key={cat.slug}
|
||||
href={getLocalizedPath(`/product-category/${cat.slug}`, locale as 'en' | 'de')}
|
||||
className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-50 text-blue-700 hover:bg-blue-100 transition-colors"
|
||||
>
|
||||
{cat.name}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<h1 className="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl mb-4">
|
||||
{product.name}
|
||||
</h1>
|
||||
|
||||
{product.sku && (
|
||||
<p className="text-sm text-gray-500 mb-4">
|
||||
{t('products.sku', locale as 'en' | 'de')}: {product.sku}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{processedShortDescription && (
|
||||
<div className="text-lg text-gray-600 mb-6">
|
||||
<ContentRenderer
|
||||
content={processedShortDescription}
|
||||
className="text-lg text-gray-600"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Excel Technical Data Section */}
|
||||
{(hasExcelData || hasExcelAttributes) && (
|
||||
<div className="border-t border-gray-200 pt-6 mb-8">
|
||||
<h3 className="text-sm font-medium text-gray-900 mb-3">
|
||||
{locale === 'de' ? 'Technische Daten' : 'Technical Data'}
|
||||
</h3>
|
||||
|
||||
{/* Configurations */}
|
||||
{hasExcelData && (
|
||||
<div className="mb-4">
|
||||
<h4 className="text-xs font-semibold text-gray-600 mb-2">
|
||||
{locale === 'de' ? 'Konfigurationen' : 'Configurations'}
|
||||
</h4>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{product.excelConfigurations!.map((config: string, index: number) => (
|
||||
<span
|
||||
key={index}
|
||||
className="inline-flex items-center px-2 py-1 rounded-md bg-gray-100 text-sm text-gray-700"
|
||||
>
|
||||
{config}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Excel Attributes */}
|
||||
{hasExcelAttributes && (
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{product.excelAttributes!.map((attr: any, index: number) => (
|
||||
<div key={index} className="bg-gray-50 rounded-lg p-3">
|
||||
<div className="text-xs font-semibold text-gray-700 mb-1">
|
||||
{attr.name}
|
||||
</div>
|
||||
<div className="text-sm text-gray-600">
|
||||
{attr.options.length === 1
|
||||
? attr.options[0]
|
||||
: attr.options.slice(0, 3).join(' / ') + (attr.options.length > 3 ? ' / ...' : '')
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Product Description */}
|
||||
{processedDescription && (
|
||||
<div className="border-t border-gray-200 pt-6 mb-8">
|
||||
<h3 className="text-sm font-medium text-gray-900 mb-3">
|
||||
{t('products.description', locale as 'en' | 'de')}
|
||||
</h3>
|
||||
<ContentRenderer
|
||||
content={processedDescription}
|
||||
className="prose prose-sm max-w-none text-gray-600"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Actions */}
|
||||
<div className="border-t border-gray-200 pt-6">
|
||||
<div className="flex flex-col sm:flex-row gap-4">
|
||||
<Link
|
||||
href={getLocalizedPath('/contact', locale as 'en' | 'de')}
|
||||
className="flex-1 inline-flex justify-center items-center px-6 py-3 border border-transparent text-base font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 transition-colors shadow-sm"
|
||||
>
|
||||
{t('products.inquire', locale as 'en' | 'de')}
|
||||
<svg className="ml-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
|
||||
</svg>
|
||||
</Link>
|
||||
<Link
|
||||
href={getLocalizedPath('/products', locale as 'en' | 'de')}
|
||||
className="flex-1 inline-flex justify-center items-center px-6 py-3 border border-gray-300 text-base font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
{t('products.backToProducts', locale as 'en' | 'de')}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Related Products */}
|
||||
{relatedProducts.length > 0 && (
|
||||
<div className="mt-20 border-t border-gray-200 pt-12">
|
||||
<h2 className="text-2xl font-bold text-gray-900 mb-6">
|
||||
{t('products.relatedProducts', locale as 'en' | 'de')}
|
||||
</h2>
|
||||
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{relatedProducts.map((relatedProduct: any) => (
|
||||
<Link
|
||||
key={relatedProduct.slug}
|
||||
href={getLocalizedPath(`/product/${relatedProduct.slug}`, locale as 'en' | 'de')}
|
||||
className="group block bg-white rounded-lg border border-gray-200 overflow-hidden hover:shadow-md transition-all"
|
||||
>
|
||||
{relatedProduct.images && relatedProduct.images.length > 0 ? (
|
||||
<div className="aspect-square bg-gray-100 overflow-hidden">
|
||||
<img
|
||||
src={relatedProduct.images[0]}
|
||||
alt={relatedProduct.name}
|
||||
className="h-full w-full object-cover group-hover:scale-105 transition-transform duration-200"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="aspect-square bg-gray-100 flex items-center justify-center">
|
||||
<svg className="h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
||||
</svg>
|
||||
</div>
|
||||
)}
|
||||
<div className="p-4">
|
||||
<h3 className="font-semibold text-gray-900 group-hover:text-blue-600 transition-colors mb-1 line-clamp-2">
|
||||
{relatedProduct.name}
|
||||
</h3>
|
||||
{relatedProduct.shortDescriptionHtml && (
|
||||
<div className="text-sm text-gray-600 line-clamp-2 mb-2">
|
||||
<ContentRenderer
|
||||
content={relatedProduct.shortDescriptionHtml}
|
||||
className="text-sm text-gray-600"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<span className="text-xs text-blue-600 font-medium">
|
||||
{t('products.viewDetails', locale as 'en' | 'de')} →
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Locale Switcher */}
|
||||
<div className="bg-gray-50 py-8">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
|
||||
<LocaleSwitcher />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
import { t } from '@/lib/i18n'
|
||||
import { ProductList } from '@/components/ProductList'
|
||||
import { getProductsForLocaleWithExcel } from '@/lib/data'
|
||||
import { Locale } from '@/lib/i18n'
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
locale: Locale;
|
||||
};
|
||||
}
|
||||
|
||||
export function generateMetadata({ params }: PageProps) {
|
||||
return {
|
||||
title: t('products.title', params.locale),
|
||||
description: t('products.description', params.locale),
|
||||
}
|
||||
}
|
||||
|
||||
export default async function ProductsPage({ params }: PageProps) {
|
||||
const products = getProductsForLocaleWithExcel(params.locale)
|
||||
|
||||
// Get unique categories
|
||||
const categories = Array.from(
|
||||
new Set(products
|
||||
.filter(p => p.locale === params.locale)
|
||||
.flatMap(p => p.categories.map(c => c.slug))
|
||||
)
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<h1 className="text-4xl font-bold mb-8">{t('products.title', params.locale)}</h1>
|
||||
|
||||
{categories.length > 0 && (
|
||||
<div className="mb-8">
|
||||
<h2 className="text-xl font-semibold mb-4">{t('products.categories', params.locale)}</h2>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{categories.map((category) => (
|
||||
<a
|
||||
key={category}
|
||||
href={`/${params.locale}/product-category/${category}`}
|
||||
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors"
|
||||
>
|
||||
{category}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{products.filter(p => p.locale === params.locale).length > 0 ? (
|
||||
<ProductList products={products.filter(p => p.locale === params.locale)} locale={params.locale} />
|
||||
) : (
|
||||
<p className="text-gray-600">{t('products.noProducts', params.locale)}</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
3715
app/globals.css
3715
app/globals.css
File diff suppressed because it is too large
Load Diff
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* KLZ Cables Global Styles
|
||||
* Minimal global styles + Tailwind CSS
|
||||
*/
|
||||
|
||||
@import "tailwindcss";
|
||||
|
||||
/*
|
||||
* ESSENTIAL GLOBAL STYLES ONLY
|
||||
* All component styles should use Tailwind utilities
|
||||
* Design tokens are available via Tailwind config
|
||||
*/
|
||||
|
||||
/* Custom Scrollbar - Essential for UX */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #0056b3;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #003d82;
|
||||
}
|
||||
|
||||
/* Focus Styles for Accessibility */
|
||||
*:focus-visible {
|
||||
outline: 2px solid #0056b3;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* Smooth scrolling */
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
/* Reduced motion support */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Print styles */
|
||||
@media print {
|
||||
.navbar,
|
||||
.cookie-consent,
|
||||
.locale-switcher,
|
||||
.submit-btn,
|
||||
.btn {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
body {
|
||||
background: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 100%;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
a::after {
|
||||
content: " (" attr(href) ")";
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import type { Metadata } from 'next';
|
||||
import { Inter } from 'next/font/google';
|
||||
import './globals.css';
|
||||
|
||||
const inter = Inter({
|
||||
subsets: ['latin', 'latin-ext'],
|
||||
display: 'swap',
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'KLZ Cables',
|
||||
description: 'Professional cable solutions for industrial applications',
|
||||
metadataBase: new URL('https://klz-cables.com'),
|
||||
alternates: {
|
||||
canonical: '/',
|
||||
languages: {
|
||||
'en': '/en',
|
||||
'de': '/de',
|
||||
},
|
||||
},
|
||||
openGraph: {
|
||||
title: 'KLZ Cables',
|
||||
description: 'Professional cable solutions for industrial applications',
|
||||
type: 'website',
|
||||
locale: 'en',
|
||||
siteName: 'KLZ Cables',
|
||||
},
|
||||
icons: {
|
||||
icon: '/favicon.ico',
|
||||
apple: '/apple-touch-icon.png',
|
||||
},
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<html>
|
||||
<head>
|
||||
<link rel="icon" href="/favicon.ico" sizes="any" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
</head>
|
||||
<body className={inter.className}>
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default function RootPage() {
|
||||
// Redirect root path to default locale
|
||||
redirect('/en');
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { MetadataRoute } from 'next';
|
||||
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
const baseUrl = process.env.SITE_URL || 'https://klz-cables.com';
|
||||
|
||||
return {
|
||||
rules: {
|
||||
userAgent: '*',
|
||||
allow: '/',
|
||||
disallow: [
|
||||
'/api/',
|
||||
'/admin/',
|
||||
'/private/',
|
||||
'/wp-admin/',
|
||||
'/wp-content/',
|
||||
'/wp-includes/',
|
||||
],
|
||||
},
|
||||
sitemap: `${baseUrl}/sitemap.xml`,
|
||||
};
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
import { MetadataRoute } from 'next';
|
||||
import { getAllPages, getAllPosts, getAllProducts, getAllCategories } from '../lib/data';
|
||||
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const baseUrl = process.env.SITE_URL || 'https://klz-cables.com';
|
||||
const urls: MetadataRoute.Sitemap = [];
|
||||
|
||||
// Add homepage
|
||||
urls.push({
|
||||
url: baseUrl,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: 'daily',
|
||||
priority: 1,
|
||||
});
|
||||
|
||||
// Add all pages
|
||||
try {
|
||||
const pages = await getAllPages();
|
||||
pages.forEach(page => {
|
||||
urls.push({
|
||||
url: `${baseUrl}/${page.slug}`,
|
||||
lastModified: new Date(page.updatedAt || Date.now()),
|
||||
changeFrequency: 'weekly',
|
||||
priority: 0.8,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not fetch pages for sitemap:', error);
|
||||
}
|
||||
|
||||
// Add blog posts
|
||||
try {
|
||||
const posts = await getAllPosts();
|
||||
posts.forEach(post => {
|
||||
urls.push({
|
||||
url: `${baseUrl}/blog/${post.slug}`,
|
||||
lastModified: new Date(post.updatedAt || Date.now()),
|
||||
changeFrequency: 'weekly',
|
||||
priority: 0.6,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not fetch posts for sitemap:', error);
|
||||
}
|
||||
|
||||
// Add products
|
||||
try {
|
||||
const products = await getAllProducts();
|
||||
products.forEach(product => {
|
||||
urls.push({
|
||||
url: `${baseUrl}/product/${product.slug}`,
|
||||
lastModified: new Date(product.updatedAt || Date.now()),
|
||||
changeFrequency: 'monthly',
|
||||
priority: 0.5,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not fetch products for sitemap:', error);
|
||||
}
|
||||
|
||||
// Add product categories
|
||||
try {
|
||||
const categories = await getAllCategories();
|
||||
categories.forEach(category => {
|
||||
urls.push({
|
||||
url: `${baseUrl}/product-category/${category.slug}`,
|
||||
lastModified: new Date(Date.now()),
|
||||
changeFrequency: 'monthly',
|
||||
priority: 0.4,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not fetch categories for sitemap:', error);
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
Reference in New Issue
Block a user