|
1 | | -export interface ChronicleConfig { |
2 | | - title: string |
3 | | - description?: string |
4 | | - url?: string |
5 | | - logo?: LogoConfig |
6 | | - theme?: ThemeConfig |
7 | | - navigation?: NavigationConfig |
8 | | - search?: SearchConfig |
9 | | - footer?: FooterConfig |
10 | | - api?: ApiConfig[] |
11 | | - llms?: LlmsConfig |
12 | | - analytics?: AnalyticsConfig |
13 | | -} |
| 1 | +import { z } from 'zod' |
14 | 2 |
|
15 | | -export interface LlmsConfig { |
16 | | - enabled?: boolean |
17 | | -} |
| 3 | +const logoSchema = z.object({ |
| 4 | + light: z.string().optional(), |
| 5 | + dark: z.string().optional(), |
| 6 | +}) |
18 | 7 |
|
19 | | -export interface AnalyticsConfig { |
20 | | - enabled?: boolean |
21 | | - googleAnalytics?: GoogleAnalyticsConfig |
22 | | -} |
| 8 | +const themeSchema = z.object({ |
| 9 | + name: z.enum(['default', 'paper']), |
| 10 | + colors: z.record(z.string(), z.string()).optional(), |
| 11 | +}) |
23 | 12 |
|
24 | | -export interface GoogleAnalyticsConfig { |
25 | | - measurementId: string |
26 | | -} |
| 13 | +const navLinkSchema = z.object({ |
| 14 | + label: z.string(), |
| 15 | + href: z.string(), |
| 16 | +}) |
27 | 17 |
|
28 | | -export interface ApiConfig { |
29 | | - name: string |
30 | | - spec: string |
31 | | - basePath: string |
32 | | - server: ApiServerConfig |
33 | | - auth?: ApiAuthConfig |
34 | | -} |
| 18 | +const socialLinkSchema = z.object({ |
| 19 | + type: z.string(), |
| 20 | + href: z.string(), |
| 21 | +}) |
35 | 22 |
|
36 | | -export interface ApiServerConfig { |
37 | | - url: string |
38 | | - description?: string |
39 | | -} |
| 23 | +const navigationSchema = z.object({ |
| 24 | + links: z.array(navLinkSchema).optional(), |
| 25 | + social: z.array(socialLinkSchema).optional(), |
| 26 | +}) |
40 | 27 |
|
41 | | -export interface ApiAuthConfig { |
42 | | - type: string |
43 | | - header: string |
44 | | - placeholder?: string |
45 | | -} |
| 28 | +const searchSchema = z.object({ |
| 29 | + enabled: z.boolean().optional(), |
| 30 | + placeholder: z.string().optional(), |
| 31 | +}) |
46 | 32 |
|
47 | | -export interface LogoConfig { |
48 | | - light?: string |
49 | | - dark?: string |
50 | | -} |
| 33 | +const apiServerSchema = z.object({ |
| 34 | + url: z.string(), |
| 35 | + description: z.string().optional(), |
| 36 | +}) |
51 | 37 |
|
52 | | -export interface ThemeConfig { |
53 | | - name: 'default' | 'paper' |
54 | | - colors?: Record<string, string> |
55 | | -} |
| 38 | +const apiAuthSchema = z.object({ |
| 39 | + type: z.string(), |
| 40 | + header: z.string(), |
| 41 | + placeholder: z.string().optional(), |
| 42 | +}) |
56 | 43 |
|
57 | | -export interface NavigationConfig { |
58 | | - links?: NavLink[] |
59 | | - social?: SocialLink[] |
60 | | -} |
| 44 | +const apiSchema = z.object({ |
| 45 | + name: z.string(), |
| 46 | + spec: z.string(), |
| 47 | + basePath: z.string(), |
| 48 | + server: apiServerSchema, |
| 49 | + auth: apiAuthSchema.optional(), |
| 50 | +}) |
61 | 51 |
|
62 | | -export interface NavLink { |
63 | | - label: string |
64 | | - href: string |
65 | | -} |
| 52 | +const footerSchema = z.object({ |
| 53 | + copyright: z.string().optional(), |
| 54 | + links: z.array(navLinkSchema).optional(), |
| 55 | +}) |
66 | 56 |
|
67 | | -export interface SocialLink { |
68 | | - type: 'github' | 'twitter' | 'discord' | string |
69 | | - href: string |
70 | | -} |
| 57 | +const llmsSchema = z.object({ |
| 58 | + enabled: z.boolean().optional(), |
| 59 | +}) |
71 | 60 |
|
72 | | -export interface SearchConfig { |
73 | | - enabled?: boolean |
74 | | - placeholder?: string |
75 | | -} |
| 61 | +const googleAnalyticsSchema = z.object({ |
| 62 | + measurementId: z.string(), |
| 63 | +}) |
76 | 64 |
|
77 | | -export interface FooterConfig { |
78 | | - copyright?: string |
79 | | - links?: NavLink[] |
80 | | -} |
| 65 | +const analyticsSchema = z.object({ |
| 66 | + enabled: z.boolean().optional(), |
| 67 | + googleAnalytics: googleAnalyticsSchema.optional(), |
| 68 | +}) |
| 69 | + |
| 70 | +export const chronicleConfigSchema = z.object({ |
| 71 | + title: z.string(), |
| 72 | + description: z.string().optional(), |
| 73 | + url: z.string().optional(), |
| 74 | + content: z.string().optional(), |
| 75 | + preset: z.string().optional(), |
| 76 | + logo: logoSchema.optional(), |
| 77 | + theme: themeSchema.optional(), |
| 78 | + navigation: navigationSchema.optional(), |
| 79 | + search: searchSchema.optional(), |
| 80 | + footer: footerSchema.optional(), |
| 81 | + api: z.array(apiSchema).optional(), |
| 82 | + llms: llmsSchema.optional(), |
| 83 | + analytics: analyticsSchema.optional(), |
| 84 | +}) |
| 85 | + |
| 86 | +export type ChronicleConfig = z.infer<typeof chronicleConfigSchema> |
| 87 | +export type LogoConfig = z.infer<typeof logoSchema> |
| 88 | +export type ThemeConfig = z.infer<typeof themeSchema> |
| 89 | +export type NavigationConfig = z.infer<typeof navigationSchema> |
| 90 | +export type NavLink = z.infer<typeof navLinkSchema> |
| 91 | +export type SocialLink = z.infer<typeof socialLinkSchema> |
| 92 | +export type SearchConfig = z.infer<typeof searchSchema> |
| 93 | +export type ApiConfig = z.infer<typeof apiSchema> |
| 94 | +export type ApiServerConfig = z.infer<typeof apiServerSchema> |
| 95 | +export type ApiAuthConfig = z.infer<typeof apiAuthSchema> |
| 96 | +export type FooterConfig = z.infer<typeof footerSchema> |
| 97 | +export type LlmsConfig = z.infer<typeof llmsSchema> |
| 98 | +export type AnalyticsConfig = z.infer<typeof analyticsSchema> |
| 99 | +export type GoogleAnalyticsConfig = z.infer<typeof googleAnalyticsSchema> |
0 commit comments