Created
March 12, 2025 14:23
-
-
Save ddotx/0e69dfc691779235d1a8bd25cc6a53f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { file, glob } from "astro/loaders"; | |
import { defineCollection, z } from "astro:content"; | |
export const collections = { | |
posts: defineCollection({ | |
loader: glob({ | |
pattern: "src/data/posts/**/*.md" | |
}), | |
}), | |
products: defineCollection({ | |
loader: file("src/data/products.json", { | |
parser: (p) => JSON.parse(p).data, | |
}), | |
schema: z.object({ | |
id: z.number(), | |
documentId: z.string(), | |
title: z.string(), | |
image: z.string().optional(), | |
SKU: z.string(), | |
cover_image: z.object({ | |
url: z.string(), | |
}) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment