164 lines
3.4 KiB
TypeScript
164 lines
3.4 KiB
TypeScript
import { defineCollection, z } from 'astro:content'
|
|
import { file, glob } from 'astro/loaders'
|
|
|
|
const iconValue = z.enum([
|
|
'cloud',
|
|
'shield',
|
|
'cpu',
|
|
'database',
|
|
'server',
|
|
'settings',
|
|
'building',
|
|
'shopping_cart',
|
|
'factory',
|
|
'heart',
|
|
'graduation_cap',
|
|
'landmark',
|
|
'rocket',
|
|
'zap',
|
|
'award',
|
|
'users',
|
|
'check_circle',
|
|
'package',
|
|
])
|
|
|
|
const colorValue = z.enum([
|
|
'blue',
|
|
'violet',
|
|
'emerald',
|
|
'orange',
|
|
'pink',
|
|
'indigo',
|
|
'cyan',
|
|
])
|
|
|
|
const vendorSchema = z.object({
|
|
name: z.string(),
|
|
slug: z.string(),
|
|
description: z.string(),
|
|
products: z.array(z.string()).optional(),
|
|
})
|
|
|
|
const categories = defineCollection({
|
|
loader: glob({ pattern: '**/*.json', base: './src/content/categories' }),
|
|
schema: z.object({
|
|
group: z.enum(['solution', 'service']),
|
|
title: z.string(),
|
|
description: z.string(),
|
|
vendors: z.array(vendorSchema),
|
|
}),
|
|
})
|
|
|
|
const heroSection = z.object({
|
|
type: z.literal('hero'),
|
|
title: z.string(),
|
|
description: z.string(),
|
|
anchor: z.string().nullable(),
|
|
badge: z.string(),
|
|
stats: z.array(z.object({ key: z.string(), value: z.string() })),
|
|
})
|
|
|
|
const servicesSection = z.object({
|
|
type: z.literal('services'),
|
|
title: z.string(),
|
|
description: z.string(),
|
|
anchor: z.string().nullable(),
|
|
cards: z.array(
|
|
z.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
icon: iconValue,
|
|
color: colorValue,
|
|
category: z.string(),
|
|
}),
|
|
),
|
|
})
|
|
|
|
const solutionsSection = z.object({
|
|
type: z.literal('solutions'),
|
|
title: z.string(),
|
|
description: z.string(),
|
|
anchor: z.string().nullable(),
|
|
cards: z.array(
|
|
z.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
footnote: z.string(),
|
|
icon: iconValue,
|
|
category: z.string(),
|
|
}),
|
|
),
|
|
})
|
|
|
|
const casesSection = z.object({
|
|
type: z.literal('cases'),
|
|
title: z.string(),
|
|
description: z.string(),
|
|
anchor: z.string().nullable(),
|
|
cards: z.array(
|
|
z.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
pretitle: z.string(),
|
|
badge: z.string(),
|
|
footnote: z.string(),
|
|
color: colorValue,
|
|
icon: iconValue,
|
|
}),
|
|
),
|
|
})
|
|
|
|
const aboutSection = z.object({
|
|
type: z.literal('about'),
|
|
title: z.string(),
|
|
description: z.string(),
|
|
anchor: z.string().nullable(),
|
|
partners: z.array(z.string()),
|
|
cards: z.array(
|
|
z.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
color: colorValue,
|
|
icon: iconValue,
|
|
}),
|
|
),
|
|
})
|
|
|
|
const homePage = defineCollection({
|
|
loader: file('./src/content/home-page.json', {
|
|
parser: (text) => ({ 'home-page': JSON.parse(text) }),
|
|
}),
|
|
schema: z.object({
|
|
sections: z.array(
|
|
z.discriminatedUnion('type', [
|
|
heroSection,
|
|
servicesSection,
|
|
solutionsSection,
|
|
casesSection,
|
|
aboutSection,
|
|
]),
|
|
),
|
|
}),
|
|
})
|
|
|
|
const contactSchema = z.object({
|
|
type: z.enum(['phone', 'working_hours', 'email', 'address']),
|
|
value: z.string(),
|
|
displayValue: z.string(),
|
|
})
|
|
|
|
const siteConfig = defineCollection({
|
|
loader: file('./src/content/site-config.json', {
|
|
parser: (text) => ({ 'site-config': JSON.parse(text) }),
|
|
}),
|
|
schema: z.object({
|
|
title: z.string(),
|
|
description: z.string().nullable(),
|
|
contacts: z.array(contactSchema),
|
|
privacyPolicy: z.string().nullable(),
|
|
termsOfUse: z.string().nullable(),
|
|
}),
|
|
})
|
|
|
|
export const collections = { categories, homePage, siteConfig }
|