chore: home page and site config seeding scripts

This commit is contained in:
Zotov Ivan Yuryevich
2026-06-22 22:14:40 +03:00
parent 460998aa6e
commit c630235176
6 changed files with 727 additions and 3 deletions

View File

@@ -1,5 +1,36 @@
import { defineCollection, z } from 'astro:content'
import { glob } from 'astro/loaders'
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(),
@@ -18,4 +49,115 @@ const categories = defineCollection({
}),
})
export const collections = { categories }
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.object({ url: z.string() }).nullable(),
termsOfUse: z.object({ url: z.string() }).nullable(),
}),
})
export const collections = { categories, homePage, siteConfig }