---
// src/pages/configurations/[slug].astro
import { getCollection } from 'astro:content';
import BaseLayout from '../../layouts/BaseLayout.astro';
// Required getStaticPaths function for dynamic routes
export async function getStaticPaths() {
try {
const configEntries = await getCollection('configurations', ({ data }) => {
// Filter out drafts in production
return import.meta.env.PROD ? !data.draft : true;
});
return configEntries.map(entry => ({
params: { slug: entry.slug },
props: { entry },
}));
} catch (error) {
console.error('Error fetching configurations:', error);
// Return empty array if collection doesn't exist or is empty
return [];
}
}
// Get the configuration from props
const { entry } = Astro.props;
// Format date helper
const formatDate = (date) => {
if (!date) return '';
const d = new Date(date);
return d.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
};
---