60 lines
1.2 KiB
TypeScript
60 lines
1.2 KiB
TypeScript
import z from "astro/zod";
|
|
import { glob } from "astro/loaders";
|
|
import { defineCollection } from "astro:content";
|
|
|
|
const writingTags = z.enum([
|
|
'emacs',
|
|
'neovim',
|
|
'keyboards',
|
|
'triathlon',
|
|
'dev',
|
|
'design',
|
|
'linux',
|
|
'nixos',
|
|
'ghostty',
|
|
'niri',
|
|
]);
|
|
|
|
const projectTags = z.enum([
|
|
'work',
|
|
'open source',
|
|
'typescript',
|
|
'golang',
|
|
'emacs lisp',
|
|
'react',
|
|
'react native',
|
|
]);
|
|
|
|
const writingSchema = z.object({
|
|
title: z.string(),
|
|
tags: z.array(writingTags),
|
|
author: z.string().default('Dennis'),
|
|
publishedAt: z.coerce.date(),
|
|
lastUpdatedAt: z.coerce.date().optional(),
|
|
isPublic: z.boolean(),
|
|
});
|
|
|
|
export type JournalData = z.infer<typeof writingSchema>;
|
|
|
|
const projectSchema = z.object({
|
|
title: z.string(),
|
|
tags: z.array(projectTags),
|
|
isWork: z.boolean(),
|
|
isLeisure: z.boolean(),
|
|
year: z.number().gte(2012),
|
|
isPublic: z.boolean(),
|
|
});
|
|
|
|
export type ProjectData = z.infer<typeof projectSchema>;
|
|
|
|
const blog = defineCollection({
|
|
loader: glob({ pattern: '**/*.md', base: 'src/content/blog' }),
|
|
schema: writingSchema
|
|
});
|
|
|
|
const projects = defineCollection({
|
|
loader: glob({ pattern: '**/*.md', base: 'src/content/projects' }),
|
|
schema: projectSchema
|
|
});
|
|
|
|
export const collections = { blog, projects };
|