diff --git a/app/[locale]/products/[...slug]/page.tsx b/app/[locale]/products/[...slug]/page.tsx index efb36b58..b64a28d0 100644 --- a/app/[locale]/products/[...slug]/page.tsx +++ b/app/[locale]/products/[...slug]/page.tsx @@ -1,17 +1,17 @@ -import { notFound } from 'next/navigation'; -import { MDXRemote } from 'next-mdx-remote/rsc'; -import { getProductBySlug, getAllProducts } from '@/lib/mdx'; -import { getDatasheetPath } from '@/lib/datasheets'; -import ProductTechnicalData from '@/components/ProductTechnicalData'; -import ProductTabs from '@/components/ProductTabs'; -import RequestQuoteForm from '@/components/RequestQuoteForm'; -import RelatedProducts from '@/components/RelatedProducts'; import ProductSidebar from '@/components/ProductSidebar'; -import Link from 'next/link'; -import Image from 'next/image'; -import { getTranslations } from 'next-intl/server'; -import { Section, Container, Badge } from '@/components/ui'; +import ProductTabs from '@/components/ProductTabs'; +import ProductTechnicalData from '@/components/ProductTechnicalData'; +import RelatedProducts from '@/components/RelatedProducts'; +import RequestQuoteForm from '@/components/RequestQuoteForm'; +import { Badge, Container, Section } from '@/components/ui'; +import { getDatasheetPath } from '@/lib/datasheets'; +import { getAllProducts, getProductBySlug } from '@/lib/mdx'; import { Metadata } from 'next'; +import { getTranslations } from 'next-intl/server'; +import { MDXRemote } from 'next-mdx-remote/rsc'; +import Image from 'next/image'; +import Link from 'next/link'; +import { notFound } from 'next/navigation'; interface ProductPageProps { params: { @@ -66,15 +66,16 @@ export async function generateMetadata({ params }: ProductPageProps): Promise

, + p: (props: any) =>

, h2: (props: any) => ( -

-

-
+
+

+
), - h3: (props: any) =>

, - ul: (props: any) =>
    , + h3: (props: any) =>

    , + ul: (props: any) =>
      , + section: (props: any) =>
      , li: (props: any) => (
    • @@ -133,7 +134,7 @@ export default async function ProductPage({ params }: ProductPageProps) { -
      +
      {filteredProducts.map((product) => ( @@ -245,7 +246,7 @@ export default async function ProductPage({ params }: ProductPageProps) {
      -
      +
      {/* Large Product Image Section */} {product.frontmatter.images && product.frontmatter.images.length > 0 && ( @@ -319,7 +320,7 @@ export default async function ProductPage({ params }: ProductPageProps) {
      {/* Main Content Area */} -
      +
      @@ -358,7 +359,7 @@ export default async function ProductPage({ params }: ProductPageProps) {
      {/* Related Products Section */} -
      +
      >({}); + if (!data) return null; const { technicalItems = [], voltageTables = [] } = data; + const toggleTable = (idx: number) => { + setExpandedTables(prev => ({ + ...prev, + [idx]: !prev[idx] + })); + }; + return (
      {technicalItems.length > 0 && ( @@ -45,58 +58,84 @@ export default function ProductTechnicalData({ data }: ProductTechnicalDataProps
      )} - {voltageTables.map((table, idx) => ( -
      -

      -
      - {table.voltageLabel !== 'Voltage unknown' && table.voltageLabel !== 'Spannung unbekannt' - ? table.voltageLabel - : 'Technical Specifications'} -

      - - {table.metaItems.length > 0 && ( -
      - {table.metaItems.map((item, mIdx) => ( -
      -
      {item.label}
      -
      {item.value} {item.unit}
      -
      - ))} -
      - )} - -
      - - - - - {table.columns.map((col, cIdx) => ( - - ))} - - - - {table.rows.map((row, rIdx) => ( - - - {row.cells.map((cell, cellIdx) => ( - - ))} - + {voltageTables.map((table, idx) => { + const isExpanded = expandedTables[idx]; + const hasManyRows = table.rows.length > 10; + + return ( +
      +

      +
      + {table.voltageLabel !== 'Voltage unknown' && table.voltageLabel !== 'Spannung unbekannt' + ? table.voltageLabel + : 'Technical Specifications'} +

      + + {table.metaItems.length > 0 && ( +
      + {table.metaItems.map((item, mIdx) => ( +
      +
      {item.label}
      +
      {item.value} {item.unit}
      +
      ))} -
      -
      - Config. - - {col.label} -
      - {row.configuration} - - {cell} -
      + + )} + +
      +
      + + + + + {table.columns.map((col, cIdx) => ( + + ))} + + + + {table.rows.map((row, rIdx) => ( + + + {row.cells.map((cell, cellIdx) => ( + + ))} + + ))} + +
      + Config. + + {col.label} +
      + {row.configuration} + + {cell} +
      +
      + + {!isExpanded && hasManyRows && ( +
      + )} +
      + + {hasManyRows && ( +
      + +
      + )}
      -
      - ))} + ); + })}
      ); } diff --git a/components/RelatedProducts.tsx b/components/RelatedProducts.tsx index 161b329d..f884131d 100644 --- a/components/RelatedProducts.tsx +++ b/components/RelatedProducts.tsx @@ -1,7 +1,7 @@ -import Link from 'next/link'; -import Image from 'next/image'; import { getAllProducts } from '@/lib/mdx'; import { getTranslations } from 'next-intl/server'; +import Image from 'next/image'; +import Link from 'next/link'; interface RelatedProductsProps { currentSlug: string; @@ -24,7 +24,7 @@ export default async function RelatedProducts({ currentSlug, categories, locale if (related.length === 0) return null; return ( -
      +

      diff --git a/messages/de.json b/messages/de.json index 0a506d13..db7840f3 100644 --- a/messages/de.json +++ b/messages/de.json @@ -172,6 +172,8 @@ "privacyNote": "Mit dem Absenden erklären Sie sich mit unserer Datenschutzerklärung einverstanden" }, "englishVersion": "Englische Version", + "showMore": "Mehr anzeigen", + "showLess": "Weniger anzeigen", "categories": { "lowVoltage": { "title": "Niederspannungskabel", diff --git a/messages/en.json b/messages/en.json index 09874dcd..064e50b8 100644 --- a/messages/en.json +++ b/messages/en.json @@ -172,6 +172,8 @@ "privacyNote": "By submitting you agree to our privacy policy" }, "englishVersion": "English Version", + "showMore": "Show More", + "showLess": "Show Less", "categories": { "lowVoltage": { "title": "Low Voltage Cables",