-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add content/preset support in chronicle.yaml with Zod validation #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,80 +1,99 @@ | ||
| export interface ChronicleConfig { | ||
| title: string | ||
| description?: string | ||
| url?: string | ||
| logo?: LogoConfig | ||
| theme?: ThemeConfig | ||
| navigation?: NavigationConfig | ||
| search?: SearchConfig | ||
| footer?: FooterConfig | ||
| api?: ApiConfig[] | ||
| llms?: LlmsConfig | ||
| analytics?: AnalyticsConfig | ||
| } | ||
| import { z } from 'zod' | ||
|
|
||
| export interface LlmsConfig { | ||
| enabled?: boolean | ||
| } | ||
| const logoSchema = z.object({ | ||
| light: z.string().optional(), | ||
| dark: z.string().optional(), | ||
| }) | ||
|
|
||
| export interface AnalyticsConfig { | ||
| enabled?: boolean | ||
| googleAnalytics?: GoogleAnalyticsConfig | ||
| } | ||
| const themeSchema = z.object({ | ||
| name: z.enum(['default', 'paper']), | ||
| colors: z.record(z.string(), z.string()).optional(), | ||
| }) | ||
|
|
||
| export interface GoogleAnalyticsConfig { | ||
| measurementId: string | ||
| } | ||
| const navLinkSchema = z.object({ | ||
| label: z.string(), | ||
| href: z.string(), | ||
| }) | ||
|
|
||
| export interface ApiConfig { | ||
| name: string | ||
| spec: string | ||
| basePath: string | ||
| server: ApiServerConfig | ||
| auth?: ApiAuthConfig | ||
| } | ||
| const socialLinkSchema = z.object({ | ||
| type: z.string(), | ||
| href: z.string(), | ||
| }) | ||
|
|
||
| export interface ApiServerConfig { | ||
| url: string | ||
| description?: string | ||
| } | ||
| const navigationSchema = z.object({ | ||
| links: z.array(navLinkSchema).optional(), | ||
| social: z.array(socialLinkSchema).optional(), | ||
| }) | ||
|
|
||
| export interface ApiAuthConfig { | ||
| type: string | ||
| header: string | ||
| placeholder?: string | ||
| } | ||
| const searchSchema = z.object({ | ||
| enabled: z.boolean().optional(), | ||
| placeholder: z.string().optional(), | ||
| }) | ||
|
|
||
| export interface LogoConfig { | ||
| light?: string | ||
| dark?: string | ||
| } | ||
| const apiServerSchema = z.object({ | ||
| url: z.string(), | ||
| description: z.string().optional(), | ||
| }) | ||
|
|
||
| export interface ThemeConfig { | ||
| name: 'default' | 'paper' | ||
| colors?: Record<string, string> | ||
| } | ||
| const apiAuthSchema = z.object({ | ||
| type: z.string(), | ||
| header: z.string(), | ||
| placeholder: z.string().optional(), | ||
| }) | ||
|
|
||
| export interface NavigationConfig { | ||
| links?: NavLink[] | ||
| social?: SocialLink[] | ||
| } | ||
| const apiSchema = z.object({ | ||
| name: z.string(), | ||
| spec: z.string(), | ||
| basePath: z.string(), | ||
| server: apiServerSchema, | ||
| auth: apiAuthSchema.optional(), | ||
| }) | ||
|
|
||
| export interface NavLink { | ||
| label: string | ||
| href: string | ||
| } | ||
| const footerSchema = z.object({ | ||
| copyright: z.string().optional(), | ||
| links: z.array(navLinkSchema).optional(), | ||
| }) | ||
|
|
||
| export interface SocialLink { | ||
| type: 'github' | 'twitter' | 'discord' | string | ||
| href: string | ||
| } | ||
| const llmsSchema = z.object({ | ||
| enabled: z.boolean().optional(), | ||
| }) | ||
|
|
||
| export interface SearchConfig { | ||
| enabled?: boolean | ||
| placeholder?: string | ||
| } | ||
| const googleAnalyticsSchema = z.object({ | ||
| measurementId: z.string(), | ||
| }) | ||
|
|
||
| export interface FooterConfig { | ||
| copyright?: string | ||
| links?: NavLink[] | ||
| } | ||
| const analyticsSchema = z.object({ | ||
| enabled: z.boolean().optional(), | ||
| googleAnalytics: googleAnalyticsSchema.optional(), | ||
| }) | ||
|
|
||
| export const chronicleConfigSchema = z.object({ | ||
| title: z.string(), | ||
| description: z.string().optional(), | ||
| url: z.string().optional(), | ||
| content: z.string().optional(), | ||
| preset: z.string().optional(), | ||
| logo: logoSchema.optional(), | ||
| theme: themeSchema.optional(), | ||
| navigation: navigationSchema.optional(), | ||
| search: searchSchema.optional(), | ||
| footer: footerSchema.optional(), | ||
| api: z.array(apiSchema).optional(), | ||
| llms: llmsSchema.optional(), | ||
| analytics: analyticsSchema.optional(), | ||
| }) | ||
|
|
||
| export type ChronicleConfig = z.infer<typeof chronicleConfigSchema> | ||
| export type LogoConfig = z.infer<typeof logoSchema> | ||
| export type ThemeConfig = z.infer<typeof themeSchema> | ||
| export type NavigationConfig = z.infer<typeof navigationSchema> | ||
| export type NavLink = z.infer<typeof navLinkSchema> | ||
| export type SocialLink = z.infer<typeof socialLinkSchema> | ||
| export type SearchConfig = z.infer<typeof searchSchema> | ||
| export type ApiConfig = z.infer<typeof apiSchema> | ||
| export type ApiServerConfig = z.infer<typeof apiServerSchema> | ||
| export type ApiAuthConfig = z.infer<typeof apiAuthSchema> | ||
| export type FooterConfig = z.infer<typeof footerSchema> | ||
| export type LlmsConfig = z.infer<typeof llmsSchema> | ||
| export type AnalyticsConfig = z.infer<typeof analyticsSchema> | ||
| export type GoogleAnalyticsConfig = z.infer<typeof googleAnalyticsSchema> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.