Initial rewrite
This commit is contained in:
parent
a5f64a3ff8
commit
0d183c8335
200 changed files with 12537 additions and 18659 deletions
108
src/content.config.ts
Normal file
108
src/content.config.ts
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
import { defineCollection } from 'astro:content';
|
||||
import { glob } from 'astro/loaders';
|
||||
import { z } from 'astro/zod';
|
||||
|
||||
const linkSchema = z.object({
|
||||
label: z.string(),
|
||||
type: z.enum([
|
||||
'source',
|
||||
'demo',
|
||||
'package',
|
||||
'paper',
|
||||
'thesis',
|
||||
'video',
|
||||
'site',
|
||||
'contact',
|
||||
]),
|
||||
url: z.string(),
|
||||
download: z.boolean().optional(),
|
||||
});
|
||||
|
||||
const thumbnailSchema = ({ image }: { image: any }) =>
|
||||
z.object({
|
||||
src: image(),
|
||||
alt: z.string(),
|
||||
});
|
||||
|
||||
const mediaSchema = ({ image }: { image: any }) =>
|
||||
z
|
||||
.object({
|
||||
type: z.enum(['image', 'video', 'diagram']),
|
||||
src: image().optional(),
|
||||
poster: image().optional(),
|
||||
mp4: z.string().optional(),
|
||||
webm: z.string().optional(),
|
||||
alt: z.string().optional(),
|
||||
decorative: z.boolean().optional(),
|
||||
caption: z.string().optional(),
|
||||
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'],
|
||||
});
|
||||
|
||||
const posts = defineCollection({
|
||||
loader: glob({ pattern: '**/*.md', base: './src/content/posts' }),
|
||||
schema: ({ image }) =>
|
||||
z.object({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
date: z.coerce.date(),
|
||||
updated: z.coerce.date().optional(),
|
||||
draft: z.boolean().default(false),
|
||||
thumbnail: thumbnailSchema({ image }),
|
||||
tags: z.array(
|
||||
z.enum([
|
||||
'ai',
|
||||
'systems',
|
||||
'graphics',
|
||||
'simulation',
|
||||
'embedded',
|
||||
'web',
|
||||
'tools',
|
||||
'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(),
|
||||
scale: z.string().optional(),
|
||||
outcome: z.string().optional(),
|
||||
audience: z
|
||||
.enum(['general', 'technical', 'recruiter-relevant'])
|
||||
.default('technical'),
|
||||
links: z.array(linkSchema).default([]),
|
||||
media: z.array(mediaSchema({ image })).default([]),
|
||||
}),
|
||||
});
|
||||
|
||||
const projects = defineCollection({
|
||||
loader: glob({ pattern: '**/*.md', base: './src/content/projects' }),
|
||||
schema: ({ image }) =>
|
||||
z.object({
|
||||
sourceProjectId: z.string(),
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
thumbnail: thumbnailSchema({ image }),
|
||||
period: z.string(),
|
||||
sortDate: z.coerce.date(),
|
||||
status: z.string().optional(),
|
||||
technologies: z.array(z.string()).default([]),
|
||||
selected: z.boolean().default(false),
|
||||
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([]),
|
||||
}),
|
||||
});
|
||||
|
||||
export const collections = { posts, projects };
|
||||
Loading…
Add table
Add a link
Reference in a new issue