Skip to content

Commit

Permalink
feat(vscode): support schema for frontmatters
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 20, 2024
1 parent 52f5e5a commit 3567a19
Show file tree
Hide file tree
Showing 11 changed files with 1,118 additions and 554 deletions.
2 changes: 1 addition & 1 deletion docs/builtin/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ See https://sli.dev/guide/animations.html#enter-leave

## `VDrag`

See https://sli.dev/guide/draggable.html
<LinkCard link="features/draggable" />

## `SlidevVideo`

Expand Down
22 changes: 22 additions & 0 deletions packages/types/src/builtin-layouts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export type BuiltinLayouts =
| '404'
| 'center'
| 'cover'
| 'default'
| 'end'
| 'error'
| 'fact'
| 'full'
| 'iframe-left'
| 'iframe-right'
| 'iframe'
| 'image-left'
| 'image-right'
| 'image'
| 'intro'
| 'none'
| 'quote'
| 'section'
| 'statement'
| 'two-cols-header'
| 'two-cols'
348 changes: 8 additions & 340 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,345 +1,15 @@
import type { TransitionGroupProps } from 'vue'
import type { ExportArgs } from './cli'
import type { SlidevThemeConfig } from './types'
import type { HeadmatterConfig } from './frontmatter'

export interface Headmatter {
/**
* Title of the slides
*/
title?: string
/**
* String template to compose title
*
* @example "%s - Slidev" - to suffix " - Slidev" to all pages
* @default '%s - Slidev'
*/
titleTemplate?: string
/**
* Theme to use for the slides
*
* @see https://sli.dev/themes/use.html
* @default 'default'
*/
theme?: string
/**
* List of Slidev addons
*
* @default []
*/
addons?: string[]
/**
* Download remote assets in local using vite-plugin-remote-assets
*
* @default false
*/
remoteAssets?: boolean | 'dev' | 'build'
/**
* Show a download button in the SPA build,
* could also be a link to custom pdf
*
* @default false
*/
download?: boolean | string
/**
* Show a copy button in code blocks
*
* @default true
*/
codeCopy?: boolean
/**
* Information shows on the built SPA
* Can be a markdown string
*
* @default false
*/
info?: string | boolean
/**
* Prefer highlighter
*
* @see https://sli.dev/custom/config-highlighter.html
* @default shiki
*/
highlighter?: 'shiki' | 'prism'
/**
* Enable Twoslash
*
* @default true
*/
twoslash?: boolean | 'dev' | 'build'
/**
* Show line numbers in code blocks
*
* @default false
*/
lineNumbers?: boolean
/**
* Force slides color schema
*
* @default 'auto'
*/
colorSchema?: 'dark' | 'light' | 'all' | 'auto'
/**
* Router mode for vue-router
*
* @default 'history'
*/
routerMode?: 'hash' | 'history'
/**
* Aspect ratio for slides
* should be like `16/9` or `1:1`
*
* @default '16/9'
*/
aspectRatio?: number
/**
* The actual width for slides canvas.
* unit in px.
*
* @default '980'
*/
canvasWidth?: number
/**
* Controls whether texts in slides are selectable
*
* @default true
*/
selectable?: boolean
/**
* Configure for themes, will inject intro root styles as
* `--slidev-theme-x` for attribute `x`
*
* This allows themes to have customization options in frontmatter
* Refer to themes' document for options avaliable
*
* @default {}
*/
themeConfig?: SlidevThemeConfig
/**
* Configure fonts for the slides and app
*
* @default {}
*/
fonts?: ResolvedFontOptions
/**
* Configure the icon for app
*
* @default 'https://cdn.jsdelivr.net/gh/slidevjs/slidev/assets/favicon.png'
*/
favicon?: string
/**
* Options for drawings
*
* @default {}
*/
drawings?: ResolvedDrawingsOptions
/**
* URL of PlantUML server used to render diagrams
*
* @default https://www.plantuml.com/plantuml
*/
plantUmlServer?: string
/**
* Enable slides recording
*
* @default 'dev'
*/
record?: boolean | 'dev' | 'build'
/**
* Expose the server to inbound requests (listen to `0.0.0.0`)
*
* Pass a string to set the password for accessing presenter mode.
*
* @default false
*/
remote?: string | boolean
/**
* Engine for Atomic CSS
*
* @see https://unocss.dev/
* @deprecated
* @default 'unocss'
*/
css?: 'unocss'
/**
* Enable presenter mode
*
* @default true
*/
presenter?: boolean | 'dev' | 'build'
/**
* Attributes to apply to the HTML element
*
* @default {}
*/
htmlAttrs?: Record<string, string>
/**
* Page transition, powered by Vue's <TransitionGroup/>
*
* Built-in transitions:
* - fade
* - fade-out
* - slide-left
* - slide-right
* - slide-up
* - slide-down
*
* @see https://sli.dev/guide/animations.html#pages-transitions
* @see https://vuejs.org/guide/built-ins/transition.html
*/
transition?: BuiltinSlideTransition | string | TransitionGroupProps | null
/**
* Suppport MDC syntax
*
* @see https://github.com/antfu/markdown-it-mdc
* @see https://content.nuxtjs.org/guide/writing/mdc
* @experimental
* @default false
*/
mdc?: boolean
/**
* Enable built-in editor
*
* @default true
*/
editor?: boolean
/**
* Enable context menu
*
* @default true
*/
contextMenu?: boolean | 'dev' | 'build' | null
/**
* Enable wake lock
*/
wakeLock?: boolean | 'dev' | 'build'
/**
* Options for export
*
* @default {}
*/
export?: ResolvedExportOptions
/**
* Force the filename used when exporting the presentation.
* The extension, e.g. .pdf, gets automatically added.
*
* @default ''
*/
exportFilename?: string | null
/**
* Enable Monaco
*
* @see https://sli.dev/custom/config-monaco.html
* @default true
*/
monaco?: boolean | 'dev' | 'build'
/**
* Where to load monaco types from
*
* - `cdn` - load from CDN with `@typescript/ata`
* - `local` - load from local node_modules
*
* @default 'local'
*/
monacoTypesSource?: 'cdn' | 'local' | 'none'
/**
* Additional node packages to load as monaco types
*
* @default []
*/
monacoTypesAdditionalPackages?: string[]
/**
* Packages to ignore when loading monaco types
*
* @default []
*/
monacoTypesIgnorePackages?: string[]
/**
* Additional local modules to load as dependencies of monaco runnable
*
* @default []
*/
monacoRunAdditionalDeps?: string[]
export interface ResolvedSlidevConfigSub {
export: ResolvedExportOptions
drawings: ResolvedDrawingsOptions
fonts: ResolvedFontOptions
}

export interface SlidevConfig extends Required<Headmatter> {
}

export interface FontOptions {
/**
* Sans serif fonts (default fonts for most text)
*/
sans?: string | string[]
/**
* Serif fonts
*/
serif?: string | string[]
/**
* Monospace fonts, for code blocks and etc.
*/
mono?: string | string[]
/**
* Load webfonts for custom CSS (does not apply anywhere by default)
*/
custom?: string | string[]
/**
* Weights for fonts
*
* @default [200, 400, 600]
*/
weights?: string | (string | number)[]
/**
* Import italic fonts
*
* @default false
*/
italic?: boolean
/**
* @default 'google'
*/
provider?: 'none' | 'google'
/**
* Specify web fonts names, will detect from `sans`, `mono`, `serif` if not provided
*/
webfonts?: string[]
/**
* Specify local fonts names, be excluded from webfonts
*/
local?: string[]
/**
* Use fonts fallback
*
* @default true
*/
fallbacks?: boolean
}

export interface DrawingsOptions {
/**
* Persist the drawings to disk
* Passing string to specify the directory (default to `.slidev/drawings`)
*
* @default false
*/
persist?: boolean | string

/**
* @default true
*/
enabled?: boolean | 'dev' | 'build'

/**
* Only allow drawing from presenter mode
*
* @default false
*/
presenterOnly?: boolean

/**
* Sync drawing for all instances
*
* @default true
*/
syncAll?: boolean
export interface SlidevConfig extends
Omit<Required<HeadmatterConfig>, keyof ResolvedSlidevConfigSub>,
ResolvedSlidevConfigSub {
}

export interface ResolvedFontOptions {
Expand All @@ -365,5 +35,3 @@ export interface ResolvedExportOptions extends Omit<ExportArgs, 'entry' | 'theme
executablePath?: string
withToc?: boolean
}

export type BuiltinSlideTransition = 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'fade' | 'zoom' | 'none'
Loading

0 comments on commit 3567a19

Please sign in to comment.