From 93121c1029cbd0ebe0ce763a6f51c39e16e05b36 Mon Sep 17 00:00:00 2001
From: Emil Gulamov <125820963+mearashadowfax@users.noreply.github.com>
Date: Sat, 20 Apr 2024 14:21:18 +0400
Subject: [PATCH 1/2] Add table display for specifications
Restructured the display of product specifications into a table format, providing users with two choices: a list of items or a table.
---
src/content/config.ts | 6 +
src/content/products/a765.md | 19 +-
src/pages/products/[...slug].astro | 336 ++++++++++++++++-------------
3 files changed, 205 insertions(+), 156 deletions(-)
diff --git a/src/content/config.ts b/src/content/config.ts
index f095b80..dbb14b8 100644
--- a/src/content/config.ts
+++ b/src/content/config.ts
@@ -46,6 +46,12 @@ const productsCollection = defineCollection({
subTitle: z.string(),
})
).optional(),
+ tableData: z.array(
+ z.object({
+ feature: z.array(z.string()),
+ description: z.array(z.array(z.string())),
+ })
+ ).optional(),
blueprints: z.object({
first: image().optional(),
second: image().optional(),
diff --git a/src/content/products/a765.md b/src/content/products/a765.md
index 59e6745..3255c59 100644
--- a/src/content/products/a765.md
+++ b/src/content/products/a765.md
@@ -1,6 +1,6 @@
---
title: "SF-AB A765"
-description: "Assorted Screw Set"
+description: " "
main:
id: 2
content: |
@@ -40,15 +40,14 @@ specificationsLeft:
subTitle: "Each set includes a sufficient quantity of screws to handle a wide range of projects and tasks."
- title: "Sizes"
subTitle: "Available in various sizes to suit different project requirements, ensuring compatibility and versatility."
-specificationsRight:
- - title: "Thread Design"
- subTitle: "Precision-engineered threads ensure a tight and secure fit, providing reliable fastening for your projects."
- - title: "Durability"
- subTitle: "Designed to withstand the rigors of everyday use, delivering long-lasting performance and reliability."
- - title: "Quality Assurance"
- subTitle: "Manufactured to meet or exceed industry standards, guaranteeing consistent quality and performance."
- - title: "Applications"
- subTitle: "Suitable for a wide range of applications, including woodworking, metalworking, construction, and more."
+tableData:
+ - feature: ["Specification", "Value"]
+ description:
+ - ["Length (mm)", "Various"]
+ - ["Weight (g)", "N/A"]
+ - ["Material", "Stainless Steel"]
+ - ["Finish", "Assorted"]
+ - ["Package Contents", "Various screws in a set"]
blueprints:
first: "@/images/blueprint-1.avif"
second: "@/images/blueprint-2.avif"
diff --git a/src/pages/products/[...slug].astro b/src/pages/products/[...slug].astro
index 0e180cc..dea0251 100644
--- a/src/pages/products/[...slug].astro
+++ b/src/pages/products/[...slug].astro
@@ -27,9 +27,7 @@ const { product } = Astro.props;
const pageTitle: string = `${product.data.title} | ${SITE.title}`;
---
-
- {spec.subTitle}
-
+ {spec.subTitle}
+
- {spec.title}
-
-
+ {spec.title}
+
+
+
+
+
+ {product.data.tableData?.[0].feature?.map(
+ (header) => (
+
+
+
+ {product.data.tableData?.map((row) =>
+ // Wrap each row's content in a separate
+ {header}
+
+ )
+ )}
+ element
+ row.description.map((rowData) => (
+
+ {/* Iterate through each cell value in the row's description array */}
+ {rowData.map((cellValue) => (
+ // Render each cell value in its own
+ ))
+ )}
+
+ element
+
+ {cellValue}
+
+ ))}
+