import React, { useEffect, useState } from 'react'; import { motion } from 'framer-motion'; import { Link } from 'react-router-dom'; import { Gavel, Wallet, ShieldCheck, Smile, BookOpen, Landmark, Scale } from 'lucide-react'; // Appropriate icons for Freezone import HeroSection from '../components/HeroSection'; import Section from '../components/Section'; import FeatureCard from '../components/FeatureCard'; import matter from 'gray-matter'; // Import images const freezoneBackground = new URL('../assets/inthezone.png', import.meta.url).href; // Use Vite's import.meta.glob to import all freezone markdown files and images const freezoneModules = import.meta.glob('../content/freezone/*.md', { as: 'raw', eager: true }); const imageModules = import.meta.glob('../assets/*.jpg', { eager: true, import: 'default' }); const iconComponents = { Gavel, Wallet, ShieldCheck, Smile, BookOpen, Landmark, Scale }; const Freezone = () => { const [articles, setArticles] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { const loadArticles = async () => { try { const loadedArticles = []; for (const path in freezoneModules) { const content = freezoneModules[path]; const { data: frontmatter } = matter(content); const IconComponent = iconComponents[frontmatter.iconname]; const imagePath = `../assets/${frontmatter.image}`; // Construct full path const importedImage = imageModules[imagePath]; loadedArticles.push({ icon: IconComponent ? : , // Default icon title: frontmatter.title, description: frontmatter.description, image: importedImage, order: frontmatter.order || 999, slug: frontmatter.slug || frontmatter.title.toLowerCase().replace(/&/g, 'and').replace(/[^a-z0-9\s-]/g, '').replace(/\s+/g, '-').replace(/^-+|-+$/g, '') }); } // Sort by order (if order is defined in frontmatter) loadedArticles.sort((a, b) => a.order - b.order); setArticles(loadedArticles); } catch (error) { console.error('Error loading freezone articles:', error); } finally { setLoading(false); } }; loadArticles(); }, []); return (
{/* Hero Section */} {/* Freezone Articles Section */}
Why a Digital Freezone? Explore the core benefits of operating your HERO from a digital freezone.
{loading ? ( // Loading skeleton Array.from({ length: 4 }).map((_, index) => (
)) ) : ( articles.map((article, index) => ( )) )}
); }; export default Freezone;