/
types.ts
143 lines (124 loc) · 4.1 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
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
import type Vue from '@vitejs/plugin-vue'
import type Components from 'unplugin-vue-components/vite'
import type Layouts from 'vite-plugin-vue-layouts'
import type Markdown from 'unplugin-vue-markdown/vite'
import type Router from 'unplugin-vue-router/vite'
import type { VitePluginConfig as UnoCSSConfig } from 'unocss/vite'
import type { EditableTreeNode } from 'unplugin-vue-router'
import type { UserConfig as ViteUserConfig } from 'vite'
import type { presetAttributify, presetIcons, presetTypography, presetUno } from 'unocss'
import type { Hookable } from 'hookable'
import type { DefaultTheme, PartialDeep, ValaxyAddon, ValaxyConfig } from 'valaxy/types'
import type { ResolvedValaxyOptions } from './options'
import type { MarkdownOptions } from './plugins/markdown/types'
export type ValaxyNodeConfig<ThemeConfig = DefaultTheme.Config> = ValaxyConfig<ThemeConfig> & ValaxyExtendConfig
export type UserValaxyNodeConfig<ThemeConfig = DefaultTheme.Config> = PartialDeep<ValaxyNodeConfig<ThemeConfig>>
/**
* fn with options for theme config
*/
export type ValaxyConfigFn<ThemeConfig = DefaultTheme.Config> = (options: ResolvedValaxyOptions<ThemeConfig>) => ValaxyNodeConfig | Promise<ValaxyNodeConfig>
export type ValaxyConfigExport<ThemeConfig = DefaultTheme.Config> = ValaxyNodeConfig<ThemeConfig> | ValaxyConfigFn<ThemeConfig>
export type HookResult = Promise<void> | void
export interface ValaxyHooks {
'options:resolved': () => HookResult
'config:init': () => HookResult
/**
* @see valaxy/node/plugins/vueRouter.ts extendRoute
*/
'vue-router:extendRoute': (route: EditableTreeNode) => HookResult
'build:before': () => HookResult
'build:after': () => HookResult
}
export interface ValaxyNode {
version: string
hooks: Hookable<ValaxyHooks>
hook: ValaxyNode['hooks']['hook']
options: ResolvedValaxyOptions
}
export interface ValaxyExtendConfig {
/**
* Don't fail builds due to dead links.
*
* @default false
*/
ignoreDeadLinks?:
| boolean
| 'localhostLinks'
| (string | RegExp | ((link: string) => boolean))[]
/**
* internal modules
*/
modules: {
rss: {
/**
* enable rss
*/
enable: boolean
}
}
/**
* Markdown Feature
*/
features: {
/**
* enable katex for global
*/
katex: boolean
}
vite?: ViteUserConfig
/**
* @vitejs/plugin-vue options
* @see https://github.com/vitejs/vite-plugin-vue/blob/main/packages/plugin-vue/README.md
*/
vue?: Parameters<typeof Vue>[0] & {
isCustomElement?: ((tag: string) => boolean)[]
}
// unplugin
components?: Parameters<typeof Components>[0]
layouts?: Parameters<typeof Layouts>[0]
router?: Parameters<typeof Router>[0]
unocss?: UnoCSSConfig
/**
* unocss presets
*/
unocssPresets?: {
uno?: Parameters<typeof presetUno>[0]
attributify?: Parameters<typeof presetAttributify>[0]
icons?: Parameters<typeof presetIcons>[0]
typography?: Parameters<typeof presetTypography>[0]
}
/**
* @experimental
* Enable Vue Devtools & Valaxy Devtools
* @see https://devtools-next.vuejs.org/
*/
devtools?: boolean
/**
* for markdown
*/
markdown?: MarkdownOptions & Parameters<typeof Markdown>[0]
extendMd?: (ctx: {
route: EditableTreeNode
data: Readonly<Record<string, any>>
content: string
excerpt?: string
path: string
}) => void
addons?: ValaxyAddons
hooks?: Partial<ValaxyHooks>
}
export type ValaxyAddonLike = ValaxyAddon | false | null | undefined
export type ValaxyAddons = (ValaxyAddon | string)[] | Record<string, ValaxyAddonLike>
export type ValaxyAddonFn<ThemeConfig = DefaultTheme.Config> = (addonOptions: ValaxyAddonResolver, valaxyOptions: ResolvedValaxyOptions<ThemeConfig>) => ValaxyNodeConfig | Promise<ValaxyNodeConfig>
export type ValaxyAddonExport<ThemeConfig = DefaultTheme.Config> = ValaxyNodeConfig<ThemeConfig> | ValaxyAddonFn<ThemeConfig>
export interface ValaxyAddonResolver {
name: string
root: string
enable: boolean
global: boolean
props: Record<string, any>
options: Record<string, any>
configFile?: string
pkg: Record<string, any>
setup?: (node: ValaxyNode) => void
}