/
types.d.ts
146 lines (118 loc) · 3.25 KB
/
types.d.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import type { PluggableList, FrozenProcessor } from 'unified';
import type { Options as RemarkRehypeOptions } from 'remark-rehype';
import type { Parent } from 'unist';
import type { Thing, WithContext } from 'schema-dts';
import type { VFile } from 'vfile';
import type { Result } from 'hastscript';
export type File = [string, string];
export type Files = File[];
export type { VFile };
export type Schema = WithContext<Thing>;
export type Tree = ReturnType<FrozenProcessor['parse']>;
export type Transformers = ((vFile: VFile) => PluggableList) | PluggableList;
export type PageType = 'page' | string;
export type FrontMatter = Partial<Meta>;
export type LayoutFn = (children: Parent['children'], meta: Meta) => Result | Result[];
declare module 'VFile' {
interface VFileDataMap {
matter: FrontMatter;
tree: Tree;
structuredContent: Schema;
meta: Meta;
pathname: string;
vFiles: Record<PageType, VFile[]>;
}
}
export type BuildMetaData = (vFile: VFile, type: PageType, options: RamblerOptions) => Meta;
interface TransferrableOptions {
host: string;
name: string;
language: string;
sitemap: boolean;
manifest: false | string;
feed: false | Feed;
}
type IgnorePattern = string | RegExp | ((file: string) => Boolean);
export interface RamblerOptions extends Partial<TransferrableOptions> {
contentDir?: string | string[];
contentFiles?: string | string[];
publicDir?: string;
outputDir?: string;
watchDir?: string | string[];
ignorePattern?: IgnorePattern | IgnorePattern[];
verbose?: boolean;
watch?: boolean;
search?: boolean | Search;
formatMarkdown?: boolean;
linkFiles?: boolean;
type?: (filename: string, matter: FrontMatter) => PageType;
parsers?: PluggableList;
remarkPlugins?: PluggableList;
remarkRehypeOptions?: RemarkRehypeOptions;
rehypePlugins?: Transformers;
renderers?: PluggableList;
directives?: Record<string, any>;
defaults?: Record<PageType, Partial<PageOptions>>;
}
interface PageOptions {
layout: LayoutFn;
author: Author;
publisher: Publisher;
title: string;
description?: string;
prefetch?: string;
published?: Date;
modified?: Date;
stylesheets: string[];
scripts: string[];
sameAs?: string[];
draft?: boolean;
image?: Image;
tags?: string[];
logo: Logo;
icon: Image;
structuredContent?: {
'@type': 'WebSite' | 'Article';
};
[key: string]: unknown;
}
export interface Meta extends PageOptions, TransferrableOptions {
type: string;
pathname: string;
href: string;
bundledStylesheets: string[];
bundledScripts: string[];
pageStylesheets: string[];
pageScripts: string[];
}
type Feed = {
pathname: string;
title: string;
description?: string;
author?: string;
tags?: string[];
filter?: (type: PageType, vFile: VFile) => boolean;
};
type Search = {
outputDir?: string;
filter?: (type: PageType, vFile: VFile) => boolean;
};
interface Image {
src: string;
alt?: string;
}
interface Logo extends Image {
href: string;
}
type Author = {
name: string;
href: string;
twitter?: string;
};
type Publisher = {
name: string;
href: string;
logo: Image;
};
export type DirectiveVisitor = (node: Element, index: number, parent: Parent, vFile: VFile) => Element;
export type Directives = Record<string, DirectiveVisitor>;