refactor: extract hardcoded content into astro content collections
This commit is contained in:
19
src/content.config.ts
Normal file
19
src/content.config.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { defineCollection, z } from 'astro:content'
|
||||
import { glob } from 'astro/loaders'
|
||||
|
||||
const vendorSchema = z.object({
|
||||
name: 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({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
vendors: z.array(vendorSchema),
|
||||
}),
|
||||
})
|
||||
|
||||
export const collections = { categories }
|
||||
Reference in New Issue
Block a user