diff --git a/src/pages/all-products.astro b/src/pages/all-products.astro index 5d5d5df..7a9a5c9 100644 --- a/src/pages/all-products.astro +++ b/src/pages/all-products.astro @@ -1,61 +1,66 @@ --- import BaseLayout from '@/layouts/BaseLayout.astro'; +// Categories match the main menu in BaseLayout.astro (header dropdown order) const products = [ - // ท่อพีพีอาร์ + // ท่อพีพีอาร์ (6 items - matches main menu) { name: "ไทยพีพีอาร์", href: "/ท่อ-ppr-thai-ppr", image: "/images/products-cropped/ppr-pipe_000C.jpg", category: "ท่อพีพีอาร์" }, { name: "ท่อ PPR ตราช้าง", href: "/ท่อ-ppr-scg", image: "/images/products-cropped/ppr-scg.jpg", category: "ท่อพีพีอาร์" }, - { name: "ท่อ PP-R Poloplast", href: "/pp-r-poloplast", image: "/images/poloplast/POLOPLAST_001.png", category: "ท่อพีพีอาร์" }, - { name: "ท่อ HDPE", href: "/ท่อ-hdpe", image: "/images/products-misc/HDPE.jpg", category: "ท่อพีพีอาร์" }, - - // ท่อ UPVC/Specialty - { name: "ท่อ UPVC", href: "/ท่อ-upvc", image: "/images/products-cropped/upvc-pipe_000C.jpg", category: "ท่อ UPVC/Specialty" }, - { name: "ท่อ Syler", href: "/ท่อ-syler", image: "/images/products-misc/SYLER01.jpg", category: "ท่อ UPVC/Specialty" }, - { name: "ท่อ PVC และข้อต่อ", href: "/ท่อ-pvc-และข้อต่อ", image: "/images/products-cropped/pvc-pipe_000C.jpg", category: "ท่อ UPVC/Specialty" }, - { name: "ท่อ XYLENT", href: "/ท่อ-xy-lent", image: "/images/products-cropped/XYLENT_001.png", category: "ท่อ UPVC/Specialty" }, - - // เครื่องเชื่อมท่อ - { name: "เครื่องเชื่อม HDPE", href: "/เครื่องเชื่อม-hdpe", image: "/images/products-misc/HDPE.jpg", category: "เครื่องเชื่อมท่อ" }, - { name: "เครื่องเชื่อม PPR", href: "/เครื่องเชื่อม-ppr", image: "/images/products-misc/ppr0001.jpg", category: "เครื่องเชื่อมท่อ" }, + { name: "ท่อ HDPE", href: "/ท่อ-hdpe", image: "/images/products-cropped/hdpe001.png", category: "ท่อพีพีอาร์" }, + { name: "ท่อ UPVC", href: "/ท่อ-upvc", image: "/images/products-cropped/upvc-pipe_000C.jpg", category: "ท่อพีพีอาร์" }, + { name: "ท่อ Syler", href: "/ท่อ-syler", image: "/images/products-cropped/syler-pipe-cold-water.jpg", category: "ท่อพีพีอาร์" }, + { name: "ท่อ XYLENT", href: "/ท่อ-xy-lent", image: "/images/products-cropped/XYLENT_001.png", category: "ท่อพีพีอาร์" }, + + // เครื่องเชื่อมท่อ (4 items) + { name: "เครื่องเชื่อม HDPE", href: "/เครื่องเชื่อม-hdpe", image: "/images/HDPE-welding-crop.jpg", category: "เครื่องเชื่อมท่อ" }, + { name: "เครื่องเชื่อม PPR", href: "/เครื่องเชื่อม-ppr", image: "/images/products-misc/ppr-welding-machine-main.jpg", category: "เครื่องเชื่อมท่อ" }, { name: "Pipe Coupling", href: "/pipe-coupling", image: "/images/pipe-coupling/BG-SMC02.png", category: "เครื่องเชื่อมท่อ" }, { name: "เม็กกรู๊ฟ คับปลิ้ง", href: "/เม็กกรู๊ฟ-คับปลิ้ง", image: "/images/products-misc/MECH_001.jpg", category: "เครื่องเชื่อมท่อ" }, - - // วาล์ว - { name: "วาล์ว Valve", href: "/วาล์ว-valve", image: "/images/products-cropped/valve_000C.jpg", category: "วาล์ว" }, - { name: "DURGO วาล์วเติมอากาศ", href: "/durgo-avvs", image: "/images/products-cropped/durgo_000C.jpg", category: "วาล์ว" }, - - // ปั๊มและระบบน้ำ - { name: "ปั๊มน้ำ Water Pump", href: "/water-pump", image: "/images/products-cropped/water-pump_000C.jpg", category: "ปั๊มและระบบน้ำ" }, - { name: "ระบบกรองน้ำ", href: "/water-treatment", image: "/images/products-cropped/water-treatment_000C.jpg", category: "ปั๊มและระบบน้ำ" }, - + + // ระบบน้ำ (3 items) + { name: "วาล์ว Valve", href: "/วาล์ว-valve", image: "/images/products-cropped/valve_000C.jpg", category: "ระบบน้ำ" }, + { name: "ปั๊มน้ำ Water Pump", href: "/water-pump", image: "/images/products-cropped/water-pump_000C.jpg", category: "ระบบน้ำ" }, + { name: "ระบบกรองน้ำ", href: "/water-treatment", image: "/images/products-cropped/water-treatment_000C.jpg", category: "ระบบน้ำ" }, + + // อุปกรณ์ปรับอากาศ (3 items) { name: "กริลแอร์", href: "/grilles", image: "/images/products-cropped/grilles_000C.jpg", category: "อุปกรณ์ปรับอากาศ" }, - - // ฉนวนและรั้ว - { name: "Armaflex", href: "/armflex", image: "/images/armflex/armaflex-sheet-roll.jpg", category: "ฉนวนและรั้ว" }, - { name: "Aeroflex", href: "/aeroflex", image: "/images/aeroflex/aerocel-d-al-real.jpg", category: "ฉนวนและรั้ว" }, - { name: "Maxflex", href: "/maxflex", image: "/images/maxflex/maxflex-fsk-foil.jpg", category: "ฉนวนและรั้ว" }, - { name: "เทอร์โมเบรค Thermobreak", href: "/เทอร์โมเบรค-thermobreak", image: "/images/thermobreak/thermobreak-solarblock.png", category: "ฉนวนและรั้ว" }, - { name: "Realflex", href: "/realflex", image: "/images/products-cropped/realflex_000C.jpg", category: "ฉนวนและรั้ว" }, - { name: "ตู้ดับเพลิง", href: "/ตู้ดับเพลิง", image: "/images/products-cropped/extinguishers_000C.jpg", category: "ฉนวนและรั้ว" }, - { name: "รั้วเทวดา", href: "/รั้วเทวดา", image: "/images/tevada/LINE_ALBUM_รั้วเทวดา_260522_1.jpg", category: "ฉนวนและรั้ว" }, - { name: "ระบบรั้วไวน์แมน", href: "/ระบบรั้วไวน์แมน", image: "/images/products-cropped/vineman_000C.jpg", category: "ฉนวนและรั้ว" }, + { name: "DURGO วาล์วเติมอากาศ", href: "/durgo-avvs", image: "/images/products-cropped/durgo_000C.jpg", category: "อุปกรณ์ปรับอากาศ" }, + { name: "หัวจ่าย Ball Jet", href: "/หัวจ่าย-ball-jet", image: "/images/ball-jet/ball-jet-main-hd.jpg", category: "อุปกรณ์ปรับอากาศ" }, + + // อุปกรณ์ดับเพลิง (2 items) + { name: "ตู้ดับเพลิง", href: "/ตู้ดับเพลิง", image: "/images/products-cropped/extinguishers_000C.jpg", category: "อุปกรณ์ดับเพลิง" }, + { name: "Realflex", href: "/realflex", image: "/images/products-cropped/realflex_000C.jpg", category: "อุปกรณ์ดับเพลิง" }, + + // ฉนวนหุ้มท่อ (4 items) + { name: "Armaflex", href: "/armflex", image: "/images/armflex/armaflex-sheet-roll.jpg", category: "ฉนวนหุ้มท่อ" }, + { name: "Aeroflex", href: "/aeroflex", image: "/images/aeroflex/aerocel-d-al-real.jpg", category: "ฉนวนหุ้มท่อ" }, + { name: "Maxflex", href: "/maxflex", image: "/images/maxflex/maxflex-fsk-foil.jpg", category: "ฉนวนหุ้มท่อ" }, + { name: "เทอร์โมเบรค Thermobreak", href: "/เทอร์โมเบรค-thermobreak", image: "/images/thermobreak/thermobreak-solarblock.png", category: "ฉนวนหุ้มท่อ" }, + + // ระบบรั้ว (2 items) + { name: "รั้วเทวดา", href: "/รั้วเทวดา", image: "/images/tevada/LINE_ALBUM_รั้วเทวดา_260522_1.jpg", category: "ระบบรั้ว" }, + { name: "ระบบรั้วไวน์แมน", href: "/ระบบรั้วไวน์แมน", image: "/images/products-raw/vineman/ระบบรั้วไวน์แมน-Vineman-e1613286324569-1024x880.jpg", category: "ระบบรั้ว" }, ]; -// Get unique categories based on Header structure +// Categories match main menu in BaseLayout.astro +const categories = [ + { name: "ท่อพีพีอาร์", id: "ppr" }, + { name: "เครื่องเชื่อมท่อ", id: "welding" }, + { name: "ระบบน้ำ", id: "water" }, + { name: "อุปกรณ์ปรับอากาศ", id: "ac" }, + { name: "อุปกรณ์ดับเพลิง", id: "fire" }, + { name: "ฉนวนหุ้มท่อ", id: "insulation" }, + { name: "ระบบรั้ว", id: "fence" }, +]; + +// Compute counts dynamically const categoryCounts = {}; products.forEach(p => { categoryCounts[p.category] = (categoryCounts[p.category] || 0) + 1; }); -const categories = [ - { name: "ท่อพีพีอาร์", id: "ppr", count: 4 }, - { name: "ท่อ UPVC/Specialty", id: "upvc", count: 4 }, - { name: "เครื่องเชื่อมท่อ", id: "welding", count: 4 }, - { name: "วาล์ว", id: "valve", count: 2 }, - { name: "ปั๊มและระบบน้ำ", id: "pump", count: 2 }, - { name: "อุปกรณ์ปรับอากาศ", id: "ac", count: 1 }, - { name: "ฉนวนและรั้ว", id: "fence", count: 8 }, -]; +// Map category name to filter id +const categoryIdMap = Object.fromEntries(categories.map(c => [c.name, c.id])); --- @@ -83,7 +88,7 @@ const categories = [ {categories.map(cat => ( ))} @@ -95,18 +100,10 @@ const categories = [