valaxy 0.9.3 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,24 @@
1
1
  import { ViteSSGOptions } from 'vite-ssg';
2
+ import * as vite from 'vite';
3
+ import { UserConfig as UserConfig$1, InlineConfig } from 'vite';
4
+ import { D as DefaultThemeConfig, U as UserSiteConfig, P as PartialDeep, S as SiteConfig } from '../config-1d500fb4.js';
2
5
  import Vue from '@vitejs/plugin-vue';
3
6
  import Components from 'unplugin-vue-components/vite';
4
7
  import { VitePluginConfig } from 'unocss/vite';
5
8
  import Pages from 'vite-plugin-pages';
6
- import * as vite from 'vite';
7
- import { UserConfig, InlineConfig } from 'vite';
8
9
  import { presetUno, presetAttributify, presetIcons, presetTypography } from 'unocss';
9
- import { V as ValaxyConfig, U as UserConfig$1, P as PartialDeep, a as ValaxyThemeConfig } from '../config-1d2e9ebd.js';
10
10
  import MarkdownIt from 'markdown-it';
11
11
  import { Theme } from 'shiki';
12
12
  import Anchor from 'markdown-it-anchor';
13
13
  import { KatexOptions } from 'katex';
14
14
  import { Awaitable } from '@antfu/utils';
15
15
 
16
+ declare module 'vite' {
17
+ interface UserConfig {
18
+ ssgOptions?: ViteSSGOptions;
19
+ }
20
+ }
21
+
16
22
  interface BlockItem {
17
23
  text?: string;
18
24
  icon?: string;
@@ -63,14 +69,15 @@ interface MarkdownOptions {
63
69
  blocks?: Blocks;
64
70
  }
65
71
 
66
- interface ValaxyEntryOptions {
67
- /**
68
- * theme name
69
- */
70
- theme?: string;
71
- userRoot?: string;
72
- }
73
- interface ValaxyPluginOptions {
72
+ declare type ValaxyConfig<ThemeConfig = DefaultThemeConfig> = UserSiteConfig<ThemeConfig> & ValaxyExtendConfig;
73
+ declare type UserConfig<ThemeConfig = DefaultThemeConfig> = ValaxyConfig<ThemeConfig>;
74
+ /**
75
+ * fn with options for theme config
76
+ */
77
+ declare type ValaxyConfigFn<ThemeConfig = DefaultThemeConfig> = (options: ResolvedValaxyOptions<ThemeConfig>) => ValaxyConfig | Promise<ValaxyConfig>;
78
+ declare type ValaxyConfigExport<ThemeConfig = DefaultThemeConfig> = ValaxyConfig<ThemeConfig> | ValaxyConfigFn<ThemeConfig>;
79
+ interface ValaxyExtendConfig {
80
+ vite?: UserConfig$1;
74
81
  vue?: Parameters<typeof Vue>[0];
75
82
  components?: Parameters<typeof Components>[0];
76
83
  unocss?: VitePluginConfig;
@@ -94,11 +101,35 @@ interface ValaxyPluginOptions {
94
101
  excerpt?: string;
95
102
  path: string;
96
103
  }) => void;
104
+ addons?: ValaxyAddonOptions;
97
105
  }
98
- interface ValaxyThemePlugin extends ValaxyPluginOptions {
99
- vite?: Omit<UserConfig, 'valaxy'>;
106
+ interface ValaxyAddon {
107
+ global?: boolean;
108
+ props?: Record<string, any>;
109
+ options?: Record<string, any>;
110
+ }
111
+ declare type ValaxyAddonLike = ValaxyAddon | false | null | undefined;
112
+ declare type ValaxyAddonOptions = ([string, ValaxyAddonLike] | string)[] | Record<string, ValaxyAddonLike>;
113
+ declare type ValaxyAddonFn<ThemeConfig = DefaultThemeConfig> = (addonOptions: ValaxyAddonResolver, valaxyOptions: ResolvedValaxyOptions<ThemeConfig>) => ValaxyConfig | Promise<ValaxyConfig>;
114
+ declare type ValaxyAddonExport<ThemeConfig = DefaultThemeConfig> = ValaxyConfig<ThemeConfig> | ValaxyAddonFn<ThemeConfig>;
115
+ interface ValaxyAddonResolver {
116
+ name: string;
117
+ root: string;
118
+ enable: boolean;
119
+ global: boolean;
120
+ props: Record<string, any>;
121
+ options: Record<string, any>;
122
+ configFile?: string;
123
+ }
124
+
125
+ interface ValaxyEntryOptions {
126
+ /**
127
+ * theme name
128
+ */
129
+ theme?: string;
130
+ userRoot?: string;
100
131
  }
101
- interface ResolvedValaxyOptions {
132
+ interface ResolvedValaxyOptions<ThemeConfig = DefaultThemeConfig> {
102
133
  mode: 'dev' | 'build';
103
134
  /**
104
135
  * package.json root
@@ -118,6 +149,10 @@ interface ResolvedValaxyOptions {
118
149
  * Theme root path
119
150
  */
120
151
  themeRoot: string;
152
+ /**
153
+ * Addon root path
154
+ */
155
+ addonRoots: string[];
121
156
  /**
122
157
  * Theme name
123
158
  */
@@ -126,57 +161,65 @@ interface ResolvedValaxyOptions {
126
161
  /**
127
162
  * Valaxy Config
128
163
  */
129
- config: ValaxyConfig;
164
+ config: ValaxyConfig<ThemeConfig>;
130
165
  /**
131
166
  * config file path
132
167
  */
133
168
  configFile: string;
134
169
  pages: string[];
170
+ /**
171
+ * all addons
172
+ * Record<package-name, OptionResolver>
173
+ */
174
+ addons: ValaxyAddonResolver[];
135
175
  }
136
176
  interface ValaxyServerOptions {
137
177
  onConfigReload?: (newConfig: ValaxyConfig, config: ValaxyConfig, force?: boolean) => void;
138
178
  }
139
- declare function isPath(name: string): boolean;
179
+ declare function resolveOptions(options: ValaxyEntryOptions, mode?: ResolvedValaxyOptions['mode']): Promise<ResolvedValaxyOptions<DefaultThemeConfig>>;
180
+
181
+ /**
182
+ * merge vite.config.ts (user & theme)
183
+ * @internal
184
+ * @param param
185
+ * @param command
186
+ * @returns
187
+ */
188
+ declare function mergeViteConfigs({ userRoot, themeRoot }: ResolvedValaxyOptions, command: 'serve' | 'build'): Promise<InlineConfig>;
140
189
  /**
141
- * get theme roots
142
- * @param name
143
- * @param entry
190
+ * generate index.html from user/theme/client
191
+ * @internal
192
+ * @param
144
193
  * @returns
145
194
  */
146
- declare function getThemeRoot(name: string, entry: string): string;
147
- declare function resolveOptions(options: ValaxyEntryOptions, mode?: ResolvedValaxyOptions['mode']): Promise<ResolvedValaxyOptions>;
195
+ declare function getIndexHtml({ clientRoot, themeRoot, userRoot, config }: ResolvedValaxyOptions): Promise<string>;
148
196
 
149
- declare module 'vite' {
150
- interface UserConfig {
151
- /**
152
- * Custom internal plugin options for Valaxy (advanced)
153
- *
154
- * @see ./options.ts'
155
- */
156
- valaxy?: ValaxyPluginOptions;
157
- ssgOptions?: ViteSSGOptions;
158
- }
159
- }
197
+ declare function build(options: ResolvedValaxyOptions, viteConfig?: InlineConfig): Promise<void>;
198
+ declare function ssgBuild(options: ResolvedValaxyOptions, viteConfig?: InlineConfig): Promise<void>;
160
199
 
161
200
  /**
162
- * Type config helper
201
+ * Type site helper
163
202
  */
164
- declare function defineConfig<ThemeConfig>(config: UserConfig$1<ThemeConfig>): PartialDeep<ValaxyConfig<ThemeConfig>>;
203
+ declare function defineSite<ThemeConfig>(config: UserSiteConfig<ThemeConfig>): PartialDeep<SiteConfig<ThemeConfig>>;
165
204
  /**
166
- * Type config helper for custom theme config
205
+ * Type site helper for custom theme site
167
206
  */
168
- declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig$1<ThemeConfig>): PartialDeep<ValaxyConfig<ThemeConfig>>;
169
- declare function resolveConfig(options?: ValaxyEntryOptions): Promise<{
170
- config: ValaxyConfig<ValaxyThemeConfig>;
171
- configFile: string;
172
- theme: string;
173
- }>;
174
- declare type ThemeConfigExport = ValaxyThemePlugin | Promise<ValaxyThemePlugin> | ThemeConfigFn;
175
- declare type ThemeConfigFn = (options: ResolvedValaxyOptions) => ValaxyThemePlugin | Promise<ValaxyThemePlugin>;
176
- declare function defineThemePlugin(config: ThemeConfigExport): ThemeConfigExport;
207
+ declare function defineSiteWithTheme<ThemeConfig>(config: UserSiteConfig<ThemeConfig>): PartialDeep<SiteConfig<ThemeConfig>>;
208
+ /**
209
+ * Type valaxy config helper
210
+ */
211
+ declare function defineConfig<ThemeConfig>(config: UserConfig<ThemeConfig>): UserConfig<ThemeConfig>;
212
+ declare type ValaxyConfigExtendKey = 'vite' | 'vue' | 'unocss' | 'unocssPresets' | 'markdown' | 'extendMd';
213
+ declare type ValaxyPickConfig = Pick<ValaxyConfig, ValaxyConfigExtendKey>;
214
+ declare type ValaxyTheme<ThemeConfig = DefaultThemeConfig> = ValaxyPickConfig & {
215
+ themeConfig?: ThemeConfig;
216
+ };
217
+ declare function defineTheme<ThemeConfig = DefaultThemeConfig>(theme: ValaxyTheme<ThemeConfig> | ((options: ResolvedValaxyOptions<ThemeConfig>) => ValaxyTheme<ThemeConfig>)): ValaxyTheme<ThemeConfig> | ((options: ResolvedValaxyOptions<ThemeConfig>) => ValaxyTheme<ThemeConfig>);
218
+ declare function defineAddon(addon: ValaxyPickConfig | ((addonOptions: ValaxyAddonResolver, valaxyOptions: ResolvedValaxyOptions) => ValaxyPickConfig)): ValaxyPickConfig | ((addonOptions: ValaxyAddonResolver, valaxyOptions: ResolvedValaxyOptions) => ValaxyPickConfig);
219
+ declare const defaultSiteConfig: SiteConfig;
177
220
  declare type UnoSetup = () => Awaitable<Partial<VitePluginConfig> | undefined>;
178
221
  declare function defineUnoSetup(fn: UnoSetup): UnoSetup;
179
222
 
180
223
  declare function createServer(options: ResolvedValaxyOptions, viteConfig?: InlineConfig, serverOptions?: ValaxyServerOptions): Promise<vite.ViteDevServer>;
181
224
 
182
- export { ResolvedValaxyOptions, ThemeConfigExport, ThemeConfigFn, UnoSetup, ValaxyEntryOptions, ValaxyPluginOptions, ValaxyServerOptions, ValaxyThemePlugin, createServer, defineConfig, defineConfigWithTheme, defineThemePlugin, defineUnoSetup, getThemeRoot, isPath, resolveConfig, resolveOptions };
225
+ export { ResolvedValaxyOptions, UnoSetup, UserConfig, ValaxyAddon, ValaxyAddonExport, ValaxyAddonFn, ValaxyAddonLike, ValaxyAddonOptions, ValaxyAddonResolver, ValaxyConfig, ValaxyConfigExport, ValaxyConfigExtendKey, ValaxyConfigFn, ValaxyEntryOptions, ValaxyExtendConfig, ValaxyPickConfig, ValaxyServerOptions, ValaxyTheme, build, createServer, defaultSiteConfig, defineAddon, defineConfig, defineSite, defineSiteWithTheme, defineTheme, defineUnoSetup, getIndexHtml, mergeViteConfigs, resolveOptions, ssgBuild };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4ICNZPINjs = require('../chunk-4ICNZPIN.js');exports.createServer = _chunk4ICNZPINjs.t; exports.defineConfig = _chunk4ICNZPINjs.e; exports.defineConfigWithTheme = _chunk4ICNZPINjs.f; exports.defineThemePlugin = _chunk4ICNZPINjs.h; exports.defineUnoSetup = _chunk4ICNZPINjs.i; exports.getThemeRoot = _chunk4ICNZPINjs.m; exports.isPath = _chunk4ICNZPINjs.l; exports.resolveConfig = _chunk4ICNZPINjs.g; exports.resolveOptions = _chunk4ICNZPINjs.n;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkS7EBKLNLjs = require('../chunk-S7EBKLNL.js');exports.build = _chunkS7EBKLNLjs.q; exports.createServer = _chunkS7EBKLNLjs.s; exports.defaultSiteConfig = _chunkS7EBKLNLjs.n; exports.defineAddon = _chunkS7EBKLNLjs.m; exports.defineConfig = _chunkS7EBKLNLjs.k; exports.defineSite = _chunkS7EBKLNLjs.i; exports.defineSiteWithTheme = _chunkS7EBKLNLjs.j; exports.defineTheme = _chunkS7EBKLNLjs.l; exports.defineUnoSetup = _chunkS7EBKLNLjs.o; exports.getIndexHtml = _chunkS7EBKLNLjs.f; exports.mergeViteConfigs = _chunkS7EBKLNLjs.e; exports.resolveOptions = _chunkS7EBKLNLjs.p; exports.ssgBuild = _chunkS7EBKLNLjs.r;
@@ -1 +1 @@
1
- import{e as o,f as r,g as m,h as p,i as t,l as e,m as f,n as x,t as i}from"../chunk-WXYDKT6O.mjs";export{i as createServer,o as defineConfig,r as defineConfigWithTheme,p as defineThemePlugin,t as defineUnoSetup,f as getThemeRoot,e as isPath,m as resolveConfig,x as resolveOptions};
1
+ import{e as o,f as r,i as m,j as p,k as t,l as e,m as f,n as x,o as i,p as a,q as b,r as c,s as d}from"../chunk-6PDG5NQV.mjs";export{b as build,d as createServer,x as defaultSiteConfig,f as defineAddon,t as defineConfig,m as defineSite,p as defineSiteWithTheme,e as defineTheme,i as defineUnoSetup,r as getIndexHtml,o as mergeViteConfigs,a as resolveOptions,c as ssgBuild};
@@ -1,4 +1,4 @@
1
- export { A as AlgoliaSearchOptions, P as PartialDeep, S as SocialLink, U as UserConfig, V as ValaxyConfig, a as ValaxyThemeConfig } from '../config-1d2e9ebd.js';
1
+ export { A as AlgoliaSearchOptions, D as DefaultThemeConfig, P as PartialDeep, S as SiteConfig, a as SocialLink, U as UserSiteConfig } from '../config-1d500fb4.js';
2
2
 
3
3
  interface Post extends Record<string, any> {
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy",
3
- "version": "0.9.3",
3
+ "version": "0.10.2",
4
4
  "description": "📄 Vite & Vue powered static blog generator.",
5
5
  "author": {
6
6
  "email": "me@yunyoujun.cn",
@@ -22,11 +22,7 @@
22
22
  "import": "./dist/node/index.mjs"
23
23
  },
24
24
  "./client/*": "./client/*",
25
- "./client": {
26
- "types": "./dist/client/index.d.ts",
27
- "require": "./dist/client/index.js",
28
- "import": "./dist/client/index.mjs"
29
- },
25
+ "./client": "./client/index.ts",
30
26
  "./node": {
31
27
  "types": "./dist/node/index.d.ts",
32
28
  "require": "./dist/node/index.js",
@@ -57,23 +53,24 @@
57
53
  "@ctrl/tinycolor": "^3.4.1",
58
54
  "@iconify-json/carbon": "^1.1.6",
59
55
  "@iconify-json/ri": "^1.1.3",
60
- "@intlify/vite-plugin-vue-i18n": "^3.4.0",
56
+ "@intlify/vite-plugin-vue-i18n": "^5.0.0",
61
57
  "@vitejs/plugin-vue": "^2.3.3",
62
- "@vueuse/core": "^8.9.2",
58
+ "@vueuse/core": "^8.9.4",
63
59
  "@vueuse/head": "^0.7.6",
64
60
  "consola": "^2.15.3",
65
61
  "critters": "^0.0.16",
66
62
  "cross-spawn": "^7.0.3",
67
- "dayjs": "^1.11.3",
63
+ "dayjs": "^1.11.4",
68
64
  "ejs": "^3.1.8",
69
65
  "escape-html": "^1.0.3",
70
66
  "feed": "^4.2.2",
71
67
  "global-dirs": "^3.0.0",
72
68
  "gray-matter": "^4.0.3",
73
69
  "is-installed-globally": "^0.4.0",
70
+ "jiti": "^1.14.0",
74
71
  "katex": "^0.16.0",
75
72
  "kolorist": "^1.5.1",
76
- "lru-cache": "^7.13.0",
73
+ "lru-cache": "^7.13.1",
77
74
  "markdown-it": "^13.0.1",
78
75
  "markdown-it-anchor": "^8.6.4",
79
76
  "markdown-it-attrs": "^4.1.4",
@@ -84,12 +81,13 @@
84
81
  "markdown-it-task-lists": "^2.1.1",
85
82
  "nprogress": "^0.2.0",
86
83
  "open": "^8.4.0",
84
+ "pascal-case": "^3.1.2",
87
85
  "pinia": "^2.0.16",
88
86
  "sass": "^1.53.0",
89
87
  "shiki": "^0.10.1",
90
88
  "star-markdown-css": "^0.4.0",
91
89
  "unconfig": "^0.3.5",
92
- "unocss": "^0.44.2",
90
+ "unocss": "^0.44.5",
93
91
  "unplugin-vue-components": "^0.21.1",
94
92
  "vite": "^2.9.14",
95
93
  "vite-plugin-pages": "^0.25.0",
package/types/config.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type ValaxyThemeConfig = Record<string, any>
1
+ export type DefaultThemeConfig = Record<string, any>
2
2
 
3
3
  export interface SocialLink {
4
4
  /**
@@ -25,8 +25,8 @@ export interface AlgoliaSearchOptions {
25
25
  initialQuery?: string
26
26
  }
27
27
 
28
- // packages/valaxy/node/config.ts
29
- export interface ValaxyConfig<T = ValaxyThemeConfig> {
28
+ // shared with valaxy node and client
29
+ export interface SiteConfig<T = DefaultThemeConfig> {
30
30
  /**
31
31
  * enable auto (light/dark mode)
32
32
  * @default 'auto'
@@ -226,5 +226,4 @@ export type PartialDeep<T> = {
226
226
  * Valaxy User Config
227
227
  * @description Valaxy 用户配置
228
228
  */
229
- export type UserConfig<ThemeConfig = ValaxyThemeConfig> = PartialDeep<ValaxyConfig<ThemeConfig>>
230
-
229
+ export type UserSiteConfig<ThemeConfig = DefaultThemeConfig> = PartialDeep<SiteConfig<ThemeConfig>>