Claude improvements
This commit is contained in:
parent
a86940da30
commit
df2267a968
79 changed files with 2695 additions and 1162 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { defineCollection } from 'astro:content';
|
||||
import type { SchemaContext } from 'astro:content';
|
||||
import { glob } from 'astro/loaders';
|
||||
import { z } from 'astro/zod';
|
||||
|
||||
|
|
@ -18,13 +19,13 @@ const linkSchema = z.object({
|
|||
download: z.boolean().optional(),
|
||||
});
|
||||
|
||||
const thumbnailSchema = ({ image }: { image: any }) =>
|
||||
const thumbnailSchema = ({ image }: SchemaContext) =>
|
||||
z.object({
|
||||
src: image(),
|
||||
alt: z.string(),
|
||||
});
|
||||
|
||||
const mediaSchema = ({ image }: { image: any }) =>
|
||||
const mediaSchema = ({ image }: SchemaContext) =>
|
||||
z
|
||||
.object({
|
||||
type: z.enum(['image', 'video', 'diagram']),
|
||||
|
|
@ -38,13 +39,8 @@ const mediaSchema = ({ image }: { image: any }) =>
|
|||
transcript: z.string().optional(),
|
||||
role: z.enum(['evidence', 'og', 'inline']).default('evidence'),
|
||||
})
|
||||
.refine((item) => item.decorative || Boolean(item.alt), {
|
||||
message: 'Meaningful media needs alt text.',
|
||||
path: ['alt'],
|
||||
})
|
||||
.refine((item) => item.decorative || Boolean(item.caption), {
|
||||
message: 'Meaningful media needs a caption.',
|
||||
path: ['caption'],
|
||||
.refine((item) => item.decorative || (Boolean(item.alt) && Boolean(item.caption)), {
|
||||
message: 'Meaningful media needs both alt text and a caption.',
|
||||
});
|
||||
|
||||
const posts = defineCollection({
|
||||
|
|
@ -52,7 +48,7 @@ const posts = defineCollection({
|
|||
schema: ({ image }) =>
|
||||
z.object({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
description: z.string().max(160),
|
||||
date: z.coerce.date(),
|
||||
updated: z.coerce.date().optional(),
|
||||
draft: z.boolean().default(false),
|
||||
|
|
@ -69,9 +65,7 @@ const posts = defineCollection({
|
|||
'games',
|
||||
])
|
||||
),
|
||||
selected: z.boolean().default(false),
|
||||
featuredOrder: z.number().optional(),
|
||||
project: z.string().optional(),
|
||||
projectPeriod: z.string().optional(),
|
||||
role: z.string().optional(),
|
||||
stack: z.array(z.string()).optional(),
|
||||
|
|
@ -91,7 +85,7 @@ const projects = defineCollection({
|
|||
z.object({
|
||||
sourceProjectId: z.string(),
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
description: z.string().max(160),
|
||||
thumbnail: thumbnailSchema({ image }),
|
||||
period: z.string(),
|
||||
sortDate: z.coerce.date(),
|
||||
|
|
@ -101,7 +95,6 @@ const projects = defineCollection({
|
|||
essay: z.string().optional(),
|
||||
legacyAnchor: z.string().optional(),
|
||||
links: z.array(linkSchema).default([]),
|
||||
downloads: z.array(z.object({ label: z.string(), url: z.string() })).default([]),
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue