-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathconfig.ts
More file actions
96 lines (88 loc) · 2.7 KB
/
config.ts
File metadata and controls
96 lines (88 loc) · 2.7 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { z, defineCollection } from "astro:content";
import { relatedContent } from "../shared";
// Categories, ordered in a (rough) general-to-specific sequence for easier
// reading. Some bits that we haven't finished revising are moved lower down
// until we revisit them.
export const categories = [
"Shape",
"Color",
"Typography",
"Image",
"Transform",
"Environment", // TODO: make new category for accessibility
"3D",
"Rendering",
"Math",
"IO",
"Events",
"DOM",
"Data",
"Structure", // TODO: move to top once revised
"Constants",
"Foundation",
] as const;
const paramSchema = z.object({
name: z.string(),
description: z.string().optional(),
type: z.string().optional(),
optional: z.coerce.boolean().optional(),
rest: z.coerce.boolean().optional(),
});
const returnSchema = z.object({
description: z.string(),
type: z.string().optional(),
});
const exampleSchema = z.string();
/**
* Method schema for methods associated with a class in the Reference collection.
*/
const methodSchema = z.object({
description: z.string().optional(),
path: z.string(),
});
/**
* Property schema for properties associated with a class in the Reference collection.
*/
const propertySchema = z.object({
description: z.string().optional(),
path: z.string(),
});
/**
* Content collection for the Reference pages of the site.
*/
export const referenceSchema = z.object({
// Name of the reference item
title: z.string(),
// Module this item is within (for example: Color)
module: z.string().optional().default('Shape'),
submodule: z.string().optional(),
file: z.string(),
description: z.string().optional(),
deprecated: z.string().or(
z.boolean().transform(() => 'This will be removed in a future version of p5.js.')
).optional(),
line: z.number().or(z.string().transform((v) => parseInt(v, 10))),
params: z.array(paramSchema).optional(),
overloads: z.array(z.object({ params: z.array(paramSchema) })).optional(),
itemtype: z.string().optional(),
class: z.string().optional(),
chainable: z.coerce.boolean().optional(),
beta: z.coerce.boolean().optional(),
return: returnSchema.optional(),
example: z.array(exampleSchema).optional(),
relatedContent: relatedContent().optional(),
methods: z.record(methodSchema).optional(),
properties: z.record(propertySchema).optional(),
isConstructor: z
.boolean()
.or(z.number().transform((n: number) => !!n))
.or(z.literal("true").transform(() => true))
.or(z.literal("false").transform(() => false))
.optional(),
webgpu: z.coerce.boolean().optional(),
webgpuOnly: z.coerce.boolean().optional(),
});
export const referenceCollection = defineCollection({
type: "content",
schema: referenceSchema,
});