Skip to content

Commit

Permalink
feat(console): enhance head.tag autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 11, 2024
1 parent f5857bd commit a3eeabc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
46 changes: 41 additions & 5 deletions plugins/console/src/node/index.ts
Expand Up @@ -253,11 +253,47 @@ namespace NodeConsole {
content?: string
}

export const Head: Schema<Head> = Schema.object({
tag: Schema.string().required(),
attrs: Schema.dict(Schema.string()).role('table'),
content: Schema.string().role('textarea'),
})
export const Head: Schema<Head> = Schema.intersect([
Schema.object({
tag: Schema.union([
'title',
'link',
'meta',
'script',
'style',
Schema.string(),
]).required(),
}),
Schema.union([
Schema.object({
tag: Schema.const('title').required(),
content: Schema.string().role('textarea'),
}),
Schema.object({
tag: Schema.const('link').required(),
attrs: Schema.dict(Schema.string()).role('table'),
}),
Schema.object({
tag: Schema.const('meta').required(),
attrs: Schema.dict(Schema.string()).role('table'),
}),
Schema.object({
tag: Schema.const('script').required(),
attrs: Schema.dict(Schema.string()).role('table'),
content: Schema.string().role('textarea'),
}),
Schema.object({
tag: Schema.const('style').required(),
attrs: Schema.dict(Schema.string()).role('table'),
content: Schema.string().role('textarea'),
}),
Schema.object({
tag: Schema.string().required(),
attrs: Schema.dict(Schema.string()).role('table'),
content: Schema.string().role('textarea'),
}),
]),
])

export interface Config {
root?: string
Expand Down
10 changes: 9 additions & 1 deletion plugins/console/src/node/locales/zh-CN.yml
Expand Up @@ -6,7 +6,15 @@ open: 在应用启动后自动在浏览器中打开控制台。
head:
$desc: 自定义页面头部信息。
$inner:
tag: 标签名。
tag:
$desc: 标签名。
$inner:
- title
- link
- meta
- script
- style
- 自定义
attrs: 标签属性。
content: 标签内容。
heartbeat:
Expand Down

0 comments on commit a3eeabc

Please sign in to comment.