Skip to content

Commit eff825d

Browse files
committed
feat(schema): set navigation.icon of page as icon for preview
1 parent ca86d97 commit eff825d

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/types/schema.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ export interface Draft07DefinitionProperty {
2121
enum?: string[]
2222
additionalProperties?: boolean | Record<string, Draft07DefinitionProperty>
2323
$content?: {
24-
editor?: {
25-
input?: 'media' | 'icon' // Override the default input for the field
26-
hidden?: boolean // Do not display the field in the editor
27-
}
24+
editor?: EditorOptions
2825
}
2926
}
3027

@@ -35,3 +32,8 @@ export interface Draft07DefinitionPropertyAnyOf {
3532
export interface Draft07DefinitionPropertyAllOf {
3633
allOf: Draft07DefinitionProperty[]
3734
}
35+
36+
export interface EditorOptions {
37+
input?: 'media' | 'icon' // Override the default input for the field
38+
hidden?: boolean // Do not display the field in the editor
39+
}

src/utils/schema.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ export const pageStandardSchema: Draft07 = {
157157
},
158158
icon: {
159159
type: 'string',
160+
$content: {
161+
editor: {
162+
input: 'icon',
163+
},
164+
},
160165
},
161166
},
162167
required: [

src/utils/zod.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ZodOptionalDef, ZodType } from 'zod'
22
import { zodToJsonSchema, ignoreOverride } from 'zod-to-json-schema'
33
import { z as zod } from 'zod'
44
import { createDefu } from 'defu'
5-
import type { Draft07 } from '../types'
5+
import type { Draft07, EditorOptions } from '../types'
66

77
const defu = createDefu((obj, key, value) => {
88
if (Array.isArray(obj[key]) && Array.isArray(value)) {
@@ -21,11 +21,6 @@ declare module 'zod' {
2121
}
2222
}
2323

24-
interface EditorOptions {
25-
input?: 'media' | 'icon' // Override the default input for the field
26-
hidden?: boolean // Do not display the field in the editor
27-
}
28-
2924
export type ZodFieldType = 'ZodString' | 'ZodNumber' | 'ZodBoolean' | 'ZodDate' | 'ZodEnum'
3025
export type SqlFieldType = 'VARCHAR' | 'INT' | 'BOOLEAN' | 'DATE' | 'TEXT'
3126

@@ -62,8 +57,6 @@ export function zodToStandardSchema(schema: zod.ZodSchema, name: string): Draft0
6257
$content: {
6358
editor: def.editor,
6459
},
65-
// @deprecated Use $content.editor instead
66-
editor: def.editor,
6760
} as never
6861
}
6962

0 commit comments

Comments
 (0)