73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { defineCollection, z } from 'astro:content';
|
|
import { glob } from 'astro/loaders';
|
|
|
|
const optionalCmsImage = z.preprocess(
|
|
(value) => value === '' || value === null ? undefined : value,
|
|
z.string().regex(/^\/images\/uploads\/[A-Za-z0-9][A-Za-z0-9._-]*\.(?:jpe?g|png|webp|avif)$/).optional(),
|
|
);
|
|
|
|
const blog = defineCollection({
|
|
loader: glob({ base: './sites/blog/content/posts', pattern: '**/*.md' }),
|
|
schema: z.object({
|
|
title: z.string().min(12).max(100),
|
|
description: z.string().min(30).max(180),
|
|
pubDate: z.coerce.date(),
|
|
updatedDate: z.coerce.date().optional(),
|
|
tags: z.array(z.string().min(2).max(32)).min(1).max(4),
|
|
draft: z.boolean().default(false),
|
|
}),
|
|
});
|
|
|
|
const faq = defineCollection({
|
|
loader: glob({ base: './sites/www/content/faq', pattern: '**/*.md' }),
|
|
schema: z.object({
|
|
question: z.string().min(12).max(180),
|
|
category: z.string().min(2).max(48).default('General'),
|
|
order: z.number().int().min(0).max(99).default(0),
|
|
draft: z.boolean().default(false),
|
|
}),
|
|
});
|
|
|
|
const services = defineCollection({
|
|
loader: glob({ base: './sites/www/content/services', pattern: '**/*.md' }),
|
|
schema: z.object({
|
|
title: z.string().min(3).max(80),
|
|
price: z.string().min(2).max(48),
|
|
items: z.array(z.string().min(3).max(80)).min(1).max(8),
|
|
order: z.number().int().min(0).max(99).default(0),
|
|
featured: z.boolean().default(false),
|
|
draft: z.boolean().default(false),
|
|
}),
|
|
});
|
|
|
|
const team = defineCollection({
|
|
loader: glob({ base: './sites/www/content/team', pattern: '**/*.md' }),
|
|
schema: z.object({
|
|
name: z.string().min(3).max(80),
|
|
role: z.string().min(3).max(80),
|
|
image: optionalCmsImage,
|
|
order: z.number().int().min(0).max(99).default(0),
|
|
draft: z.boolean().default(false),
|
|
}),
|
|
});
|
|
|
|
const pageImages = defineCollection({
|
|
loader: glob({ base: './sites/www/content/page-images', pattern: '**/*.md' }),
|
|
schema: z.object({
|
|
homeHeroImage: optionalCmsImage,
|
|
homeHeroImageAlt: z.string().min(8).max(180),
|
|
homeStoryImage: optionalCmsImage,
|
|
homeStoryImageAlt: z.string().min(8).max(180),
|
|
aboutHeroImage: optionalCmsImage,
|
|
aboutHeroImageAlt: z.string().min(8).max(180),
|
|
aboutStoryImage: optionalCmsImage,
|
|
aboutStoryImageAlt: z.string().min(8).max(180),
|
|
servicesHeroImage: optionalCmsImage,
|
|
servicesHeroImageAlt: z.string().min(8).max(180),
|
|
contactHeroImage: optionalCmsImage,
|
|
contactHeroImageAlt: z.string().min(8).max(180),
|
|
}),
|
|
});
|
|
|
|
export const collections = { blog, faq, services, team, pageImages };
|