-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
types.ts
92 lines (78 loc) · 2.23 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import type * as hast from 'hast';
import type * as mdast from 'mdast';
import type {
all as Handlers,
one as Handler,
Options as RemarkRehypeOptions,
} from 'remark-rehype';
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
import type * as unified from 'unified';
import type { VFile } from 'vfile';
export type { Node } from 'unist';
export type MarkdownAstroData = {
frontmatter: Record<string, any>;
};
export type RemarkPlugin<PluginParameters extends any[] = any[]> = unified.Plugin<
PluginParameters,
mdast.Root
>;
export type RemarkPlugins = (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
export type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugin<
PluginParameters,
hast.Root
>;
export type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
export type RemarkRehype = Omit<RemarkRehypeOptions, 'handlers' | 'unknownHandler'> & {
handlers?: typeof Handlers;
handler?: typeof Handler;
};
export interface ShikiConfig {
langs?: ILanguageRegistration[];
theme?: Theme | IThemeRegistration;
wrap?: boolean | null;
}
export interface AstroMarkdownOptions {
drafts?: boolean;
syntaxHighlight?: 'shiki' | 'prism' | false;
shikiConfig?: ShikiConfig;
remarkPlugins?: RemarkPlugins;
rehypePlugins?: RehypePlugins;
remarkRehype?: RemarkRehype;
gfm?: boolean;
smartypants?: boolean;
}
export interface MarkdownRenderingOptions extends AstroMarkdownOptions {
/** @internal */
fileURL?: URL;
/** @internal */
$?: {
scopedClassName: string | null;
};
isAstroFlavoredMd?: boolean;
/** Used to prevent relative image imports from `src/content/` */
isExperimentalContentCollections?: boolean;
/** Used to prevent relative image imports from `src/content/` */
contentDir: URL;
/** Used for frontmatter injection plugins */
frontmatter?: Record<string, any>;
}
export interface MarkdownHeading {
depth: number;
slug: string;
text: string;
}
export interface MarkdownMetadata {
headings: MarkdownHeading[];
source: string;
html: string;
}
export interface MarkdownVFile extends VFile {
data: {
__astroHeadings?: MarkdownHeading[];
};
}
export interface MarkdownRenderingResult {
metadata: MarkdownMetadata;
vfile: VFile;
code: string;
}