-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
123 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { MarkdownTransformContext, ResolvedSlidevOptions, SlidevPluginOptions, SlidevServerOptions } from '@slidev/types' | ||
import { createHooks } from 'hookable' | ||
import type MarkdownIt from 'markdown-it' | ||
import type { ViteDevServer } from 'vite' | ||
|
||
export interface SlidevServerHooks { | ||
/** | ||
* Hook for the Vite server created | ||
*/ | ||
'server:created': (server: ViteDevServer) => void | ||
/** | ||
* Hook for the Vite config resolved | ||
*/ | ||
'vite:configResolved': (config: any) => void | ||
/** | ||
* Setting up the markdown-it instance | ||
*/ | ||
'markdown:setup': (md: MarkdownIt) => Promise<void> | void | ||
/** | ||
* Transforming markdown content before any Slidev transformations | ||
* You may manipulate MagicString instance | ||
* The hook has to be sync | ||
*/ | ||
'markdown:transform:pre': (context: MarkdownTransformContext, id: string) => void | ||
/** | ||
* Transforming markdown content after Slidev transformations | ||
* You may manipulate MagicString instance | ||
* The hook has to be sync | ||
*/ | ||
'markdown:transform:post': (context: MarkdownTransformContext, id: string) => void | ||
} | ||
|
||
export class SlidevServerApp { | ||
public readonly hooks = createHooks<SlidevServerHooks>() | ||
public viteServer?: ViteDevServer | ||
|
||
constructor( | ||
public options: ResolvedSlidevOptions, | ||
public pluginOptions: SlidevPluginOptions, | ||
public serverOptions?: SlidevServerOptions, | ||
) { | ||
} | ||
} |
This file contains 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 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 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 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 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 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
Oops, something went wrong.