-
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathblog.ts
More file actions
37 lines (32 loc) · 989 Bytes
/
blog.ts
File metadata and controls
37 lines (32 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { isAtIdentifierString, type AtIdentifierString } from '@atproto/lex'
import { custom, object, string, optional, array, boolean, pipe, isoDate } from 'valibot'
import type { InferOutput } from 'valibot'
export const AuthorSchema = object({
name: string(),
blueskyHandle: optional(
pipe(
string(),
custom<AtIdentifierString>(v => typeof v === 'string' && isAtIdentifierString(v)),
),
),
})
export const BlogPostSchema = object({
authors: array(AuthorSchema),
title: string(),
date: pipe(string(), isoDate()),
description: string(),
path: string(),
slug: string(),
excerpt: optional(string()),
tags: optional(array(string())),
draft: optional(boolean()),
})
export type Author = InferOutput<typeof AuthorSchema>
export interface ResolvedAuthor extends Author {
avatar: string | null
profileUrl: string | null
}
/**
* Inferred type for blog post frontmatter
*/
export type BlogPostFrontmatter = InferOutput<typeof BlogPostSchema>