7d72aeeae8
* docs: update README for `content/` * chore: update env * feat: update blog to use content collections * chore: remove with-content starter * fix: single quotes -> double * feat: update docs starter to content collections * refactor: config -> consts * chore: import type * edit: Astro will -> Use Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * chore: remove unused null check * nit: spacing * nit: `as Props` 1 Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * nit: `as Props` 2 Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * chore: consistent CONSTS usage * chore: `type` imports at top * chore: consistent quote usage on YAML * chore: remove `as Props` from docs Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
21 lines
502 B
TypeScript
21 lines
502 B
TypeScript
import { defineCollection, z } from 'astro:content';
|
|
|
|
const blog = defineCollection({
|
|
// Type-check frontmatter using a schema
|
|
schema: z.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
// Transform string to Date object
|
|
pubDate: z
|
|
.string()
|
|
.or(z.date())
|
|
.transform((val) => new Date(val)),
|
|
updatedDate: z
|
|
.string()
|
|
.optional()
|
|
.transform((str) => (str ? new Date(str) : undefined)),
|
|
heroImage: z.string().optional(),
|
|
}),
|
|
});
|
|
|
|
export const collections = { blog };
|