Skip to content

Commit 59133d2

Browse files
mneniekermanx
andauthored
fix: frontmatter types and vscode schemas (#2063)
Co-authored-by: _Kerman <[email protected]>
1 parent 29f0aec commit 59133d2

File tree

4 files changed

+99
-88
lines changed

4 files changed

+99
-88
lines changed

docs/custom/index.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,18 @@ src: undefined # or string
147147
title: undefined # or string
148148
# defines the transition between the slide and the next one
149149
# Learn more: https://sli.dev/guide/animations.html#slide-transitions
150-
transition: undefined # or string | TransitionProps
150+
transition: undefined # or BuiltinSlideTransition | string | TransitionGroupProps | null
151151
# custom zoom scale
152152
# useful for slides with a lot of content
153153
zoom: 1
154154
# used as positions of draggable elements
155155
# Learn more: https://sli.dev/features/draggable.html
156-
dragPos: {} # type: Record<string,string>
156+
dragPos: {} # type: Record<string, string>
157157
---
158158
```
159159

160+
Check out the [type definition](https://github.com/slidevjs/slidev/blob/main/packages/types/src/frontmatter.ts#L260) for more details.
161+
160162
## Directory Structure
161163

162164
Slidev uses directory structure conventions to minimalize the configuration surface and make extensions in functionality flexible and intuitive.

packages/types/src/frontmatter.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { BuiltinLayouts } from './builtin-layouts'
22
import type { SlidevThemeConfig } from './types'
33

4-
export interface Headmatter extends HeadmatterConfig, Frontmatter {
4+
export interface Headmatter extends HeadmatterConfig, Omit<Frontmatter, 'title'> {
55
/**
66
* Default frontmatter options applied to all slides
77
*/
@@ -296,18 +296,23 @@ export interface Frontmatter extends TransitionOptions {
296296
*/
297297
disabled?: boolean
298298
/**
299-
* hide the slide for the `<Toc>` components
299+
* Hide the slide for the `<Toc>` components
300300
*
301301
* See https://sli.dev/builtin/components#toc
302302
*/
303303
hideInToc?: boolean
304304
/**
305-
* Override the title level for the <TitleRenderer> and <Toc> components
305+
* Override the title for the `<TitleRenderer>` and `<Toc>` components
306+
* Only if `title` has also been declared
307+
*/
308+
title?: string
309+
/**
310+
* Override the title level for the `<TitleRenderer>` and `<Toc>` components
306311
* Only if `title` has also been declared
307312
*/
308313
level?: number
309314
/**
310-
* Create a route alias that can be used in the URL or with the <Link> component
315+
* Create a route alias that can be used in the URL or with the `<Link>` component
311316
*/
312317
routeAlias?: string
313318
/**
@@ -321,7 +326,7 @@ export interface Frontmatter extends TransitionOptions {
321326
*
322327
* See https://sli.dev/features/draggable
323328
*/
324-
dragPos?: Record<string, string>[]
329+
dragPos?: Record<string, string>
325330
/**
326331
* Includes a markdown file
327332
*

packages/vscode/schema/frontmatter.json

+14-12
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,23 @@
8383
},
8484
"hideInToc": {
8585
"type": "boolean",
86-
"description": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc",
87-
"markdownDescription": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc"
86+
"description": "Hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc",
87+
"markdownDescription": "Hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc"
88+
},
89+
"title": {
90+
"type": "string",
91+
"description": "Override the title for the `<TitleRenderer>` and `<Toc>` components Only if `title` has also been declared",
92+
"markdownDescription": "Override the title for the `<TitleRenderer>` and `<Toc>` components\nOnly if `title` has also been declared"
8893
},
8994
"level": {
9095
"type": "number",
91-
"description": "Override the title level for the <TitleRenderer> and <Toc> components Only if `title` has also been declared",
92-
"markdownDescription": "Override the title level for the <TitleRenderer> and <Toc> components\nOnly if `title` has also been declared"
96+
"description": "Override the title level for the `<TitleRenderer>` and `<Toc>` components Only if `title` has also been declared",
97+
"markdownDescription": "Override the title level for the `<TitleRenderer>` and `<Toc>` components\nOnly if `title` has also been declared"
9398
},
9499
"routeAlias": {
95100
"type": "string",
96-
"description": "Create a route alias that can be used in the URL or with the <Link> component",
97-
"markdownDescription": "Create a route alias that can be used in the URL or with the <Link> component"
101+
"description": "Create a route alias that can be used in the URL or with the `<Link>` component",
102+
"markdownDescription": "Create a route alias that can be used in the URL or with the `<Link>` component"
98103
},
99104
"zoom": {
100105
"type": "number",
@@ -103,12 +108,9 @@
103108
"default": 1
104109
},
105110
"dragPos": {
106-
"type": "array",
107-
"items": {
108-
"type": "object",
109-
"additionalProperties": {
110-
"type": "string"
111-
}
111+
"type": "object",
112+
"additionalProperties": {
113+
"type": "string"
112114
},
113115
"description": "Store the positions of draggable elements Normally you don't need to set this manually\n\nSee https://sli.dev/features/draggable",
114116
"markdownDescription": "Store the positions of draggable elements\nNormally you don't need to set this manually\n\nSee https://sli.dev/features/draggable"

packages/vscode/schema/headmatter.json

+71-69
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,6 @@
55
"Headmatter": {
66
"type": "object",
77
"properties": {
8-
"transition": {
9-
"anyOf": [
10-
{
11-
"$ref": "#/definitions/BuiltinSlideTransition"
12-
},
13-
{
14-
"type": "string"
15-
},
16-
{
17-
"$ref": "#/definitions/TransitionGroupProps"
18-
},
19-
{
20-
"type": "null"
21-
}
22-
],
23-
"description": "Page transition, powered by Vue's `<TransitionGroup/>`\n\nBuilt-in transitions:\n- fade\n- fade-out\n- slide-left\n- slide-right\n- slide-up\n- slide-down\n\nSee https://sli.dev/guide/animations.html#pages-transitions\n\nSee https://vuejs.org/guide/built-ins/transition.html",
24-
"markdownDescription": "Page transition, powered by Vue's `<TransitionGroup/>`\n\nBuilt-in transitions:\n- fade\n- fade-out\n- slide-left\n- slide-right\n- slide-up\n- slide-down\n\nSee https://sli.dev/guide/animations.html#pages-transitions\n\nSee https://vuejs.org/guide/built-ins/transition.html"
25-
},
268
"layout": {
279
"anyOf": [
2810
{
@@ -83,18 +65,18 @@
8365
},
8466
"hideInToc": {
8567
"type": "boolean",
86-
"description": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc",
87-
"markdownDescription": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc"
68+
"description": "Hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc",
69+
"markdownDescription": "Hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc"
8870
},
8971
"level": {
9072
"type": "number",
91-
"description": "Override the title level for the <TitleRenderer> and <Toc> components Only if `title` has also been declared",
92-
"markdownDescription": "Override the title level for the <TitleRenderer> and <Toc> components\nOnly if `title` has also been declared"
73+
"description": "Override the title level for the `<TitleRenderer>` and `<Toc>` components Only if `title` has also been declared",
74+
"markdownDescription": "Override the title level for the `<TitleRenderer>` and `<Toc>` components\nOnly if `title` has also been declared"
9375
},
9476
"routeAlias": {
9577
"type": "string",
96-
"description": "Create a route alias that can be used in the URL or with the <Link> component",
97-
"markdownDescription": "Create a route alias that can be used in the URL or with the <Link> component"
78+
"description": "Create a route alias that can be used in the URL or with the `<Link>` component",
79+
"markdownDescription": "Create a route alias that can be used in the URL or with the `<Link>` component"
9880
},
9981
"zoom": {
10082
"type": "number",
@@ -103,12 +85,9 @@
10385
"default": 1
10486
},
10587
"dragPos": {
106-
"type": "array",
107-
"items": {
108-
"type": "object",
109-
"additionalProperties": {
110-
"type": "string"
111-
}
88+
"type": "object",
89+
"additionalProperties": {
90+
"type": "string"
11291
},
11392
"description": "Store the positions of draggable elements Normally you don't need to set this manually\n\nSee https://sli.dev/features/draggable",
11493
"markdownDescription": "Store the positions of draggable elements\nNormally you don't need to set this manually\n\nSee https://sli.dev/features/draggable"
@@ -118,6 +97,24 @@
11897
"description": "Includes a markdown file\n\nSee https://sli.dev/guide/syntax.html#importing-slides",
11998
"markdownDescription": "Includes a markdown file\n\nSee https://sli.dev/guide/syntax.html#importing-slides"
12099
},
100+
"transition": {
101+
"anyOf": [
102+
{
103+
"$ref": "#/definitions/BuiltinSlideTransition"
104+
},
105+
{
106+
"type": "string"
107+
},
108+
{
109+
"$ref": "#/definitions/TransitionGroupProps"
110+
},
111+
{
112+
"type": "null"
113+
}
114+
],
115+
"description": "Page transition, powered by Vue's `<TransitionGroup/>`\n\nBuilt-in transitions:\n- fade\n- fade-out\n- slide-left\n- slide-right\n- slide-up\n- slide-down\n\nSee https://sli.dev/guide/animations.html#pages-transitions\n\nSee https://vuejs.org/guide/built-ins/transition.html",
116+
"markdownDescription": "Page transition, powered by Vue's `<TransitionGroup/>`\n\nBuilt-in transitions:\n- fade\n- fade-out\n- slide-left\n- slide-right\n- slide-up\n- slide-down\n\nSee https://sli.dev/guide/animations.html#pages-transitions\n\nSee https://vuejs.org/guide/built-ins/transition.html"
117+
},
121118
"title": {
122119
"type": "string",
123120
"description": "Title of the slides",
@@ -492,7 +489,36 @@
492489
"description": "Default frontmatter options applied to all slides",
493490
"markdownDescription": "Default frontmatter options applied to all slides"
494491
}
495-
}
492+
},
493+
"required": [
494+
"transition"
495+
]
496+
},
497+
"BuiltinLayouts": {
498+
"type": "string",
499+
"enum": [
500+
"404",
501+
"center",
502+
"cover",
503+
"default",
504+
"end",
505+
"error",
506+
"fact",
507+
"full",
508+
"iframe-left",
509+
"iframe-right",
510+
"iframe",
511+
"image-left",
512+
"image-right",
513+
"image",
514+
"intro",
515+
"none",
516+
"quote",
517+
"section",
518+
"statement",
519+
"two-cols-header",
520+
"two-cols"
521+
]
496522
},
497523
"BuiltinSlideTransition": {
498524
"type": "string",
@@ -575,32 +601,6 @@
575601
}
576602
}
577603
},
578-
"BuiltinLayouts": {
579-
"type": "string",
580-
"enum": [
581-
"404",
582-
"center",
583-
"cover",
584-
"default",
585-
"end",
586-
"error",
587-
"fact",
588-
"full",
589-
"iframe-left",
590-
"iframe-right",
591-
"iframe",
592-
"image-left",
593-
"image-right",
594-
"image",
595-
"intro",
596-
"none",
597-
"quote",
598-
"section",
599-
"statement",
600-
"two-cols-header",
601-
"two-cols"
602-
]
603-
},
604604
"SlidevThemeConfig": {
605605
"type": "object",
606606
"additionalProperties": {
@@ -858,18 +858,23 @@
858858
},
859859
"hideInToc": {
860860
"type": "boolean",
861-
"description": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc",
862-
"markdownDescription": "hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc"
861+
"description": "Hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc",
862+
"markdownDescription": "Hide the slide for the `<Toc>` components\n\nSee https://sli.dev/builtin/components#toc"
863+
},
864+
"title": {
865+
"type": "string",
866+
"description": "Override the title for the `<TitleRenderer>` and `<Toc>` components Only if `title` has also been declared",
867+
"markdownDescription": "Override the title for the `<TitleRenderer>` and `<Toc>` components\nOnly if `title` has also been declared"
863868
},
864869
"level": {
865870
"type": "number",
866-
"description": "Override the title level for the <TitleRenderer> and <Toc> components Only if `title` has also been declared",
867-
"markdownDescription": "Override the title level for the <TitleRenderer> and <Toc> components\nOnly if `title` has also been declared"
871+
"description": "Override the title level for the `<TitleRenderer>` and `<Toc>` components Only if `title` has also been declared",
872+
"markdownDescription": "Override the title level for the `<TitleRenderer>` and `<Toc>` components\nOnly if `title` has also been declared"
868873
},
869874
"routeAlias": {
870875
"type": "string",
871-
"description": "Create a route alias that can be used in the URL or with the <Link> component",
872-
"markdownDescription": "Create a route alias that can be used in the URL or with the <Link> component"
876+
"description": "Create a route alias that can be used in the URL or with the `<Link>` component",
877+
"markdownDescription": "Create a route alias that can be used in the URL or with the `<Link>` component"
873878
},
874879
"zoom": {
875880
"type": "number",
@@ -878,12 +883,9 @@
878883
"default": 1
879884
},
880885
"dragPos": {
881-
"type": "array",
882-
"items": {
883-
"type": "object",
884-
"additionalProperties": {
885-
"type": "string"
886-
}
886+
"type": "object",
887+
"additionalProperties": {
888+
"type": "string"
887889
},
888890
"description": "Store the positions of draggable elements Normally you don't need to set this manually\n\nSee https://sli.dev/features/draggable",
889891
"markdownDescription": "Store the positions of draggable elements\nNormally you don't need to set this manually\n\nSee https://sli.dev/features/draggable"

0 commit comments

Comments
 (0)