valaxy 0.4.0 → 0.6.1
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.
- package/README.md +0 -4
- package/{src/client → client}/App.vue +0 -0
- package/{src/client/composables/search/index.ts → client/app/data.ts} +0 -0
- package/{src/client → client}/components/AppLink.vue +0 -0
- package/client/components/PostCard.vue +84 -0
- package/{src/client → client}/components/PostList.vue +0 -0
- package/{src/client → client}/components/README.md +0 -0
- package/{src/client → client}/components/ValaxyBg.vue +0 -0
- package/{src/client → client}/components/ValaxyCopyright.vue +0 -0
- package/{src/client → client}/components/ValaxyFooter.vue +1 -1
- package/{src/client → client}/components/ValaxyHamburger.vue +0 -0
- package/client/components/ValaxyMd.vue +74 -0
- package/{src/client → client}/components/ValaxyOverlay.vue +0 -0
- package/{src/client → client}/components/ValaxyPagination.vue +0 -0
- package/{src/client → client}/components/ValaxyRightSidebar.vue +0 -0
- package/{src/client → client}/components/ValaxySidebar.vue +0 -0
- package/{src/client → client}/components/ValaxyToc.vue +3 -3
- package/{src/client → client}/composables/category.ts +0 -0
- package/{src/client → client}/composables/comments/index.ts +0 -0
- package/{src/client → client}/composables/comments/twikoo.ts +0 -0
- package/{src/client → client}/composables/comments/waline.ts +0 -0
- package/{src/client → client}/composables/common.ts +0 -0
- package/client/composables/copy-code.ts +92 -0
- package/{src/client → client}/composables/dark.ts +0 -0
- package/client/composables/features/index.ts +0 -0
- package/{src/client → client}/composables/helper.ts +0 -0
- package/{src/client → client}/composables/index.ts +1 -1
- package/{src/client → client}/composables/layout.ts +0 -0
- package/client/composables/outline.ts +168 -0
- package/{src/client → client}/composables/post.ts +0 -0
- package/client/composables/search/index.ts +0 -0
- package/{src/client → client}/composables/sidebar.ts +46 -1
- package/{src/client → client}/composables/tag.ts +0 -0
- package/{src/client → client}/composables/widgets/aplayer.ts +0 -0
- package/{src/client → client}/composables/widgets/backToTop.ts +0 -0
- package/{src/client → client}/composables/widgets/codepen.ts +0 -0
- package/{src/client → client}/composables/widgets/index.ts +0 -0
- package/client/config.ts +75 -0
- package/{src/client → client}/index.html +0 -0
- package/{src/client → client}/index.ts +0 -0
- package/{src/client → client}/layouts/404.vue +0 -0
- package/{src/client → client}/layouts/README.md +0 -0
- package/{src/client → client}/locales/README.md +0 -0
- package/{src/client → client}/locales/en.yml +1 -0
- package/{src/client → client}/locales/zh-CN.yml +4 -3
- package/{src/client → client}/main.ts +4 -1
- package/{src/client → client}/modules/README.md +0 -0
- package/{src/client → client}/modules/nprogress.ts +0 -0
- package/{src/client → client}/modules/pinia.ts +0 -0
- package/{src/client → client}/modules/valaxy.ts +19 -7
- package/{src/client → client}/pages/README.md +0 -0
- package/{src/client → client}/pages/[...all].vue +0 -0
- package/{src/client → client}/pages/hi/[name].vue +0 -0
- package/{src/client → client}/pages/index.vue +0 -0
- package/{src/client → client}/pages/page/[page].vue +0 -0
- package/{src/client → client}/shims.d.ts +7 -1
- package/{src/client → client}/stores/app.ts +0 -0
- package/{src/client → client}/stores/user.ts +0 -0
- package/{src/client → client}/styles/common/button.scss +0 -0
- package/client/styles/common/code.scss +231 -0
- package/{src/client → client}/styles/common/custom-blocks.scss +0 -0
- package/{src/client → client}/styles/common/hamburger.scss +0 -0
- package/{src/client → client}/styles/common/markdown.scss +0 -2
- package/client/styles/common/scrollbar.scss +28 -0
- package/{src/client → client}/styles/common/sidebar.scss +0 -0
- package/{src/client → client}/styles/common/transition.scss +0 -0
- package/client/styles/css-vars.scss +62 -0
- package/{src/client → client}/styles/global/helper.scss +0 -0
- package/{src/client → client}/styles/global/i18n.scss +0 -0
- package/{src/client → client}/styles/global/index.scss +0 -0
- package/{src/client → client}/styles/global/nprogress.scss +0 -0
- package/{src/client → client}/styles/global/reset.scss +0 -0
- package/{src/client → client}/styles/index.scss +0 -0
- package/{src/client → client}/styles/mixins/config.scss +0 -0
- package/{src/client → client}/styles/mixins/index.scss +0 -0
- package/{src/client → client}/styles/mixins/size.scss +0 -0
- package/{src/client → client}/styles/mixins/variable.scss +0 -0
- package/{src/client → client}/styles/palette.scss +21 -2
- package/client/styles/third/katex.scss +3 -0
- package/client/styles/vars.scss +41 -0
- package/{src/client → client}/styles/widgets/banner.scss +0 -0
- package/{src/client → client}/types.ts +0 -0
- package/{src/client → client}/utils/helper.ts +22 -0
- package/{src/client → client}/utils/index.ts +0 -0
- package/client/utils/sidebar.ts +26 -0
- package/{src/client → client}/utils/time.ts +0 -0
- package/config/index.ts +18 -0
- package/dist/chunk-EAN2KU6W.mjs +1 -0
- package/dist/chunk-HMUGSKPK.mjs +40 -0
- package/dist/chunk-U5OMNIOK.js +1 -0
- package/dist/chunk-ZHHNO5RK.js +40 -0
- package/dist/{config-de04677b.d.ts → config-112ac884.d.ts} +37 -14
- package/dist/index.d.ts +65 -111
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/cli.js +7 -11
- package/dist/node/cli.mjs +7 -11
- package/dist/node/index.d.ts +3 -2
- package/dist/node/index.js +1 -1
- package/dist/node/index.mjs +1 -1
- package/{src/index.ts → index.ts} +1 -0
- package/{src/node → node}/build.ts +0 -0
- package/{src/node → node}/cli.ts +3 -2
- package/node/config.ts +156 -0
- package/{src/node → node}/index.ts +0 -0
- package/{src/node → node}/markdown/check.ts +0 -0
- package/node/markdown/highlight.ts +38 -0
- package/{src/node → node}/markdown/index.ts +30 -16
- package/{src/node → node}/markdown/markdown-it/container.ts +0 -0
- package/{src/node → node}/markdown/markdown-it/headings.ts +0 -0
- package/{src/node → node}/markdown/markdown-it/highlightLines.ts +1 -1
- package/{src/node → node}/markdown/markdown-it/katex.ts +0 -0
- package/{src/node → node}/markdown/markdown-it/parseHeader.ts +0 -0
- package/node/markdown/markdownToVue.ts +274 -0
- package/{src/node → node}/markdown/slugify.ts +0 -0
- package/{src/node → node}/options.ts +18 -2
- package/{src/node → node}/plugins/extendConfig.ts +5 -3
- package/node/plugins/index.ts +224 -0
- package/{src/node → node}/plugins/preset.ts +8 -8
- package/{src/node → node}/plugins/unocss.ts +0 -0
- package/{src/node → node}/plugins/valaxy.ts +0 -0
- package/{src/node → node}/rss.ts +1 -1
- package/{src/node → node}/server.ts +0 -0
- package/{src/node → node}/shims.d.ts +0 -5
- package/{src/node → node}/utils/cli.ts +1 -1
- package/node/utils/getGitTimestamp.ts +13 -0
- package/node/utils/index.ts +59 -0
- package/node/utils/net.ts +20 -0
- package/{src/node → node}/vite.ts +5 -1
- package/package.json +32 -13
- package/shared/index.ts +1 -0
- package/tsup.config.ts +7 -4
- package/{src/types → types}/config.ts +31 -108
- package/types/data.ts +31 -0
- package/{src/types → types}/index.ts +1 -0
- package/{src/types → types}/posts.ts +6 -1
- package/dist/chunk-6LIOFBAA.mjs +0 -1
- package/dist/chunk-HRARZPSA.js +0 -83
- package/dist/chunk-N6HD5SHF.mjs +0 -83
- package/dist/chunk-V3BMKLEW.js +0 -1
- package/src/client/components/PostCard.vue +0 -68
- package/src/client/components/ValaxyMd.vue +0 -71
- package/src/client/composables/features/index.ts +0 -1
- package/src/client/composables/features/katex.ts +0 -15
- package/src/client/composables/search/algolia.ts +0 -115
- package/src/client/config.ts +0 -51
- package/src/client/styles/common/code.scss +0 -207
- package/src/client/styles/common/scrollbar.scss +0 -34
- package/src/client/styles/css-vars.scss +0 -39
- package/src/client/styles/vars.scss +0 -27
- package/src/node/config.ts +0 -52
- package/src/node/markdown/highlight.ts +0 -50
- package/src/node/plugins/index.ts +0 -120
- package/src/node/plugins/markdown.ts +0 -57
- package/src/node/utils/index.ts +0 -26
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { PartialDeep } from 'type-fest';
|
|
2
2
|
import { VitePluginConfig } from 'unocss/vite';
|
|
3
3
|
import MarkdownIt from 'markdown-it';
|
|
4
|
+
import { Theme } from 'shiki';
|
|
4
5
|
import Anchor from 'markdown-it-anchor';
|
|
5
6
|
import { KatexOptions } from 'katex';
|
|
6
|
-
import Markdown from 'vite-plugin-md';
|
|
7
7
|
|
|
8
|
+
declare type ThemeOptions = Theme | {
|
|
9
|
+
light: Theme;
|
|
10
|
+
dark: Theme;
|
|
11
|
+
};
|
|
8
12
|
interface MarkdownOptions extends MarkdownIt.Options {
|
|
9
13
|
config?: (md: MarkdownIt) => void;
|
|
10
14
|
anchor?: {
|
|
@@ -15,10 +19,12 @@ interface MarkdownOptions extends MarkdownIt.Options {
|
|
|
15
19
|
[key: string]: any;
|
|
16
20
|
};
|
|
17
21
|
katex?: KatexOptions;
|
|
22
|
+
/**
|
|
23
|
+
* shiki
|
|
24
|
+
*/
|
|
25
|
+
theme?: ThemeOptions;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
declare type ViteMdOptions = Parameters<typeof Markdown>[0];
|
|
21
|
-
|
|
22
28
|
declare type ValaxyThemeConfig = Record<string, any>;
|
|
23
29
|
interface SocialLink {
|
|
24
30
|
/**
|
|
@@ -33,6 +39,16 @@ interface SocialLink {
|
|
|
33
39
|
icon: string;
|
|
34
40
|
color: string;
|
|
35
41
|
}
|
|
42
|
+
interface AlgoliaSearchOptions {
|
|
43
|
+
enable: boolean;
|
|
44
|
+
appId: string;
|
|
45
|
+
apiKey: string;
|
|
46
|
+
indexName: string;
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
searchParameters?: any;
|
|
49
|
+
disableUserPersonalization?: boolean;
|
|
50
|
+
initialQuery?: string;
|
|
51
|
+
}
|
|
36
52
|
interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
37
53
|
/**
|
|
38
54
|
* Default language
|
|
@@ -43,6 +59,7 @@ interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
43
59
|
/**
|
|
44
60
|
* You site url in web, required for ssg & rss
|
|
45
61
|
* @description 站点的 URL,SSG & RSS 需要(譬如生成版权处文章永久链接)
|
|
62
|
+
* @default '/'
|
|
46
63
|
*/
|
|
47
64
|
url: string;
|
|
48
65
|
/**
|
|
@@ -84,6 +101,10 @@ interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
84
101
|
message: string;
|
|
85
102
|
};
|
|
86
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* show last updated time by git
|
|
106
|
+
*/
|
|
107
|
+
lastUpdated: boolean;
|
|
87
108
|
/**
|
|
88
109
|
* icon for your website
|
|
89
110
|
*/
|
|
@@ -104,13 +125,8 @@ interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
104
125
|
* search
|
|
105
126
|
*/
|
|
106
127
|
search: {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
appId: string;
|
|
110
|
-
apiKey: string;
|
|
111
|
-
indexName: string;
|
|
112
|
-
chunkSize: number;
|
|
113
|
-
};
|
|
128
|
+
enable: boolean;
|
|
129
|
+
algolia: AlgoliaSearchOptions;
|
|
114
130
|
};
|
|
115
131
|
/**
|
|
116
132
|
* comment: waline/...
|
|
@@ -125,6 +141,15 @@ interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
125
141
|
envId: string;
|
|
126
142
|
};
|
|
127
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* Markdown Feature
|
|
146
|
+
*/
|
|
147
|
+
features: {
|
|
148
|
+
/**
|
|
149
|
+
* enable katex for global
|
|
150
|
+
*/
|
|
151
|
+
katex: boolean;
|
|
152
|
+
};
|
|
128
153
|
/**
|
|
129
154
|
* The name of theme
|
|
130
155
|
* @description 主题名称
|
|
@@ -189,14 +214,12 @@ interface ValaxyConfig<T = ValaxyThemeConfig> {
|
|
|
189
214
|
/**
|
|
190
215
|
* for markdown
|
|
191
216
|
*/
|
|
192
|
-
markdown: ViteMdOptions;
|
|
193
217
|
markdownIt: MarkdownOptions;
|
|
194
218
|
}
|
|
195
219
|
/**
|
|
196
220
|
* Valaxy User Config
|
|
197
221
|
* @description Valaxy 用户配置
|
|
198
222
|
*/
|
|
199
|
-
declare type UserConfig<
|
|
200
|
-
declare const defaultValaxyConfig: ValaxyConfig;
|
|
223
|
+
declare type UserConfig<ThemeConfig = ValaxyThemeConfig> = PartialDeep<ValaxyConfig<ThemeConfig>>;
|
|
201
224
|
|
|
202
|
-
export { SocialLink as S, UserConfig as U, ValaxyConfig as V, ValaxyThemeConfig as a
|
|
225
|
+
export { AlgoliaSearchOptions as A, SocialLink as S, UserConfig as U, ValaxyConfig as V, ValaxyThemeConfig as a };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { InjectionKey, ComputedRef, Ref, StyleValue } from 'vue';
|
|
3
|
-
import { V as ValaxyConfig, a as ValaxyThemeConfig } from './config-
|
|
4
|
-
export { S as SocialLink, U as UserConfig, V as ValaxyConfig, a as ValaxyThemeConfig
|
|
3
|
+
import { V as ValaxyConfig, a as ValaxyThemeConfig, U as UserConfig } from './config-112ac884.js';
|
|
4
|
+
export { A as AlgoliaSearchOptions, S as SocialLink, U as UserConfig, V as ValaxyConfig, a as ValaxyThemeConfig } from './config-112ac884.js';
|
|
5
|
+
import * as valaxy_theme_yun from 'valaxy-theme-yun';
|
|
6
|
+
import { ThemeConfig, YunTheme } from 'valaxy-theme-yun';
|
|
7
|
+
import * as type_fest_source_partial_deep from 'type-fest/source/partial-deep';
|
|
5
8
|
import 'type-fest';
|
|
6
9
|
import 'unocss/vite';
|
|
7
10
|
import 'markdown-it';
|
|
11
|
+
import 'shiki';
|
|
8
12
|
import 'markdown-it-anchor';
|
|
9
13
|
import 'katex';
|
|
10
|
-
import 'vite-plugin-md';
|
|
11
14
|
|
|
12
15
|
interface Post extends Record<string, any> {
|
|
13
16
|
/**
|
|
@@ -113,120 +116,51 @@ interface Post extends Record<string, any> {
|
|
|
113
116
|
* @description 是否为草稿
|
|
114
117
|
*/
|
|
115
118
|
draft?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* cover
|
|
121
|
+
* @description 封面图片
|
|
122
|
+
*/
|
|
123
|
+
cover?: string;
|
|
116
124
|
/**
|
|
117
125
|
* enable markdown-body class
|
|
118
126
|
* @description 是否启用默认的 markdown 样式
|
|
119
127
|
*/
|
|
120
|
-
markdown
|
|
128
|
+
markdown?: boolean;
|
|
121
129
|
}
|
|
122
130
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
safelist: string[];
|
|
128
|
-
colors: {
|
|
129
|
-
/**
|
|
130
|
-
* primary color
|
|
131
|
-
* @default '#0078E7'
|
|
132
|
-
*/
|
|
133
|
-
primary: string;
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* 首页标语
|
|
137
|
-
*/
|
|
138
|
-
banner: {
|
|
139
|
-
enable: boolean;
|
|
140
|
-
/**
|
|
141
|
-
* 标题
|
|
142
|
-
*/
|
|
143
|
-
title: string;
|
|
144
|
-
};
|
|
145
|
-
bg_image: {
|
|
146
|
-
enable: boolean;
|
|
147
|
-
url: string;
|
|
148
|
-
dark?: string;
|
|
149
|
-
opacity?: number;
|
|
150
|
-
};
|
|
131
|
+
interface Header {
|
|
132
|
+
level: number;
|
|
133
|
+
title: string;
|
|
134
|
+
slug: string;
|
|
151
135
|
/**
|
|
152
|
-
*
|
|
153
|
-
* https://say.elpsy.cn
|
|
136
|
+
* i18n
|
|
154
137
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
icon: string;
|
|
167
|
-
color: string;
|
|
168
|
-
}[];
|
|
169
|
-
/**
|
|
170
|
-
* footer
|
|
171
|
-
*/
|
|
172
|
-
footer: {
|
|
173
|
-
/**
|
|
174
|
-
* 建站于
|
|
175
|
-
*/
|
|
176
|
-
since: number;
|
|
177
|
-
/**
|
|
178
|
-
* Icon between year and copyright info.
|
|
179
|
-
*/
|
|
180
|
-
icon: {
|
|
181
|
-
/**
|
|
182
|
-
* icon name, i-xxx
|
|
183
|
-
*/
|
|
184
|
-
name: string;
|
|
185
|
-
animated: boolean;
|
|
186
|
-
color: string;
|
|
187
|
-
url: string;
|
|
188
|
-
title: string;
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Powered by valaxy & valaxy-theme-${name}, default is yun
|
|
192
|
-
*/
|
|
193
|
-
powered: boolean;
|
|
194
|
-
/**
|
|
195
|
-
* Chinese Users | 中国用户
|
|
196
|
-
* 备案 ICP
|
|
197
|
-
* 国内用户需要在网站页脚展示备案 ICP 号
|
|
198
|
-
* https://beian.miit.gov.cn/
|
|
199
|
-
*/
|
|
200
|
-
beian: {
|
|
201
|
-
enable: boolean;
|
|
202
|
-
/**
|
|
203
|
-
* 苏ICP备xxxxxxxx号
|
|
204
|
-
*/
|
|
205
|
-
icp: string;
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* post card types
|
|
210
|
-
*/
|
|
211
|
-
types: Record<string, {
|
|
212
|
-
color: string;
|
|
213
|
-
icon: string;
|
|
214
|
-
}>;
|
|
215
|
-
/**
|
|
216
|
-
* 菜单栏
|
|
217
|
-
*/
|
|
218
|
-
menu: {
|
|
219
|
-
custom: {
|
|
220
|
-
title: string;
|
|
221
|
-
url: string;
|
|
222
|
-
icon: string;
|
|
223
|
-
};
|
|
224
|
-
};
|
|
138
|
+
lang?: string;
|
|
139
|
+
}
|
|
140
|
+
interface PageData {
|
|
141
|
+
path: string;
|
|
142
|
+
relativePath: string;
|
|
143
|
+
title: string;
|
|
144
|
+
titleTemplate?: string;
|
|
145
|
+
description: string;
|
|
146
|
+
headers: Header[];
|
|
147
|
+
frontmatter: Post;
|
|
148
|
+
lastUpdated?: number;
|
|
225
149
|
}
|
|
150
|
+
interface PageDataPayload {
|
|
151
|
+
path: string;
|
|
152
|
+
pageData: PageData;
|
|
153
|
+
}
|
|
154
|
+
declare type HeadConfig = [string, Record<string, string>] | [string, Record<string, string>, string];
|
|
226
155
|
|
|
156
|
+
interface ValaxyContext {
|
|
157
|
+
userRoot: string;
|
|
158
|
+
}
|
|
227
159
|
declare const valaxyConfigSymbol: InjectionKey<ComputedRef<ValaxyConfig<ThemeConfig>>>;
|
|
228
160
|
declare const valaxyConfigRef: vue.ShallowRef<ValaxyConfig<ValaxyThemeConfig>>;
|
|
161
|
+
declare const valaxyContextRef: vue.ShallowRef<ValaxyContext>;
|
|
229
162
|
declare function initConfig(): ComputedRef<ValaxyConfig<ValaxyThemeConfig>>;
|
|
163
|
+
declare function initContext(): ComputedRef<ValaxyContext>;
|
|
230
164
|
declare function useConfig(): ComputedRef<ValaxyConfig<ThemeConfig>>;
|
|
231
165
|
/**
|
|
232
166
|
* getThemeConfig
|
|
@@ -240,6 +174,10 @@ declare function useThemeConfig(): ComputedRef<ThemeConfig & {
|
|
|
240
174
|
homepage?: string | undefined;
|
|
241
175
|
};
|
|
242
176
|
}>;
|
|
177
|
+
interface ValaxyData<T = any> {
|
|
178
|
+
page: Ref<PageData>;
|
|
179
|
+
theme: Ref<T>;
|
|
180
|
+
}
|
|
243
181
|
|
|
244
182
|
interface BaseCategory {
|
|
245
183
|
total: number;
|
|
@@ -273,7 +211,10 @@ declare function usePostList(params?: {
|
|
|
273
211
|
* get all page
|
|
274
212
|
* @returns
|
|
275
213
|
*/
|
|
276
|
-
declare function usePageList(): vue.ComputedRef<
|
|
214
|
+
declare function usePageList(): vue.ComputedRef<({
|
|
215
|
+
path: string;
|
|
216
|
+
excerpt: unknown;
|
|
217
|
+
} & Post)[]>;
|
|
277
218
|
/**
|
|
278
219
|
* get prev and next post
|
|
279
220
|
* @param path
|
|
@@ -324,11 +265,6 @@ declare function useFrontmatter(): vue.ComputedRef<Post>;
|
|
|
324
265
|
*/
|
|
325
266
|
declare function useFullUrl(): vue.ComputedRef<string>;
|
|
326
267
|
|
|
327
|
-
/**
|
|
328
|
-
* use katex css cdn
|
|
329
|
-
*/
|
|
330
|
-
declare function useKatex(): void;
|
|
331
|
-
|
|
332
268
|
/**
|
|
333
269
|
* trigger show invisible element
|
|
334
270
|
* @param target
|
|
@@ -369,6 +305,14 @@ declare function useBackToTop(options?: {
|
|
|
369
305
|
|
|
370
306
|
declare function useCodePen(): void;
|
|
371
307
|
|
|
308
|
+
declare function useSidebar(): {
|
|
309
|
+
isOpen: Ref<boolean>;
|
|
310
|
+
sidebar: vue.ComputedRef<any>;
|
|
311
|
+
hasSidebar: vue.ComputedRef<boolean>;
|
|
312
|
+
open: () => void;
|
|
313
|
+
close: () => void;
|
|
314
|
+
toggle: () => void;
|
|
315
|
+
};
|
|
372
316
|
declare function useActiveSidebarLinks(container: Ref<HTMLElement>, marker: Ref<HTMLElement>): void;
|
|
373
317
|
|
|
374
318
|
declare function useTwikoo(options?: {}): void;
|
|
@@ -389,6 +333,7 @@ declare function wrap(el: HTMLElement, className: string): void;
|
|
|
389
333
|
* 包裹表格,添加 class 以控制 table 样式
|
|
390
334
|
*/
|
|
391
335
|
declare const wrapTable: (container?: HTMLElement | Document) => void;
|
|
336
|
+
declare function throttleAndDebounce(fn: () => void, delay: number): () => void;
|
|
392
337
|
|
|
393
338
|
/**
|
|
394
339
|
* use dayjs format date
|
|
@@ -404,4 +349,13 @@ declare function formatDate(date: string | number | Date, template?: string): st
|
|
|
404
349
|
*/
|
|
405
350
|
declare function sortByDate(posts: Post[], desc?: boolean): Post[];
|
|
406
351
|
|
|
407
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Type config helper
|
|
354
|
+
*/
|
|
355
|
+
declare function defineConfig(config: UserConfig<YunTheme.Config>): type_fest_source_partial_deep.PartialObjectDeep<ValaxyConfig<valaxy_theme_yun.ThemeConfig>>;
|
|
356
|
+
/**
|
|
357
|
+
* Type config helper for custom theme config
|
|
358
|
+
*/
|
|
359
|
+
declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig<ThemeConfig>): type_fest_source_partial_deep.PartialObjectDeep<ValaxyConfig<ThemeConfig>>;
|
|
360
|
+
|
|
361
|
+
export { BaseCategory, Categories, Category, HeadConfig, Header, PageData, PageDataPayload, ParentCategory, Post, PostCategory, Tags, ValaxyData, defineConfig, defineConfigWithTheme, formatDate, initConfig, initContext, isDark, isParentCategory, random, sortByDate, throttleAndDebounce, toggleDark, useActiveSidebarLinks, useAplayer, useBackToTop, useCategory, useCodePen, useConfig, useFrontmatter, useFullUrl, useInvisibleElement, useLayout, usePageList, usePostList, usePostProperty, usePostTitle, usePrevNext, useSidebar, useTag, useTags, useThemeConfig, useTwikoo, useWaline, valaxyConfigRef, valaxyConfigSymbol, valaxyContextRef, wrap, wrapTable };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkV3BMKLEWjs = require('./chunk-V3BMKLEW.js');var _config = require('@valaxyjs/config'); var _config2 = _interopRequireDefault(_config);var _vue = require('vue');function C(t){let e=JSON.parse(t);return import.meta.env.DEV?_vue.readonly.call(void 0, e):e}var U=Symbol("valaxy:config"),T= exports.valaxyConfigRef =_vue.shallowRef.call(void 0, C(_config2.default));import.meta.hot&&import.meta.hot.accept("/@valaxyjs/config",t=>{T.value=C(t.default)});function Ct(){return _vue.computed.call(void 0, ()=>T.value)}function g(){let t=_vue.inject.call(void 0, U);if(!t)throw new Error("[Valaxy] config not properly injected in qpp");return t}function P(){let t=g();return _vue.computed.call(void 0, ()=>t.value.themeConfig)}var _vuerouter = require('vue-router');var _vuei18n = require('vue-i18n');function Pt(t,e){return Math.random()*(e-t)+t}function q(t,e){let o=document.createElement("div");o.className=e,t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),o.appendChild(t)}var bt=(t=document)=>{t.querySelectorAll("table").forEach(e=>{let o=document.createElement("div");o.className="table-container",q(e,"table-container")})};var _dayjs = require('dayjs'); var _dayjs2 = _interopRequireDefault(_dayjs);function Et(t,e="YYYY-MM-DD"){return _dayjs2.default.call(void 0, t).format(e)}function y(t,e=!0){return t.sort((o,n)=>{let s=+new Date(o.date||""),r=+new Date(n.date||"");return e?r-s:s-r})}var Ut=t=>{let{locale:e}=_vuei18n.useI18n.call(void 0, );return _vue.computed.call(void 0, ()=>{let o=e.value==="zh-CN"?"zh":e.value;return t.value[`title_${o}`]||t.value.title})};function h(t={}){let e=_vuerouter.useRouter.call(void 0, );return _vue.computed.call(void 0, ()=>{let o=e.getRoutes().filter(r=>r.path.startsWith("/posts")&&r.meta.frontmatter&&r.meta.frontmatter.date).filter(r=>!r.path.endsWith(".html")).filter(r=>!t.type||r.meta.frontmatter.type===t.type).map(r=>Object.assign({path:r.path,excerpt:r.meta.excerpt},r.meta.frontmatter)),n=y(o.filter(r=>r.top)).sort((r,l)=>l.top-r.top),s=y(o.filter(r=>!r.top));return n.concat(s)})}function qt(){let t=_vuerouter.useRouter.call(void 0, );return _vue.computed.call(void 0, ()=>t.getRoutes().map(o=>Object.assign({path:o.path,excerpt:o.meta.excerpt},o.meta.frontmatter)))}function Bt(t){let e=_vuerouter.useRoute.call(void 0, ),o=_vue.computed.call(void 0, ()=>t||e.path),n=h(),s=_vue.computed.call(void 0, ()=>{let i=-1;return n.value.find((a,c)=>a.path===o.value?(i=c,!0):!1),i}),r=_vue.computed.call(void 0, ()=>s.value-1>=0?n.value[s.value-1]:null),l=_vue.computed.call(void 0, ()=>s.value+1<n.value.length?n.value[s.value+1]:null);return[r,l]}function zt(t){if(!t)return{color:"",icon:"",styles:{}};let e=P();t in e.value.types||(t="link");let o=e.value.types[t].color,n=e.value.types[t].icon,s=_vue.computed.call(void 0, ()=>({"--card-c-primary":t&&o}));return{color:o,icon:n,styles:s}}var Yt=t=>t.children;function $t(t,e=[]){var s;e.length||(e=_vue.unref.call(void 0, h()));let o={total:e.length,children:new Map([["Uncategorized",{total:0,posts:[]}]])},n=o.children.get("Uncategorized");if(e.forEach(r=>{if(r.categories)if(Array.isArray(r.categories)){let l=r.categories.length,i=o;r.categories.forEach((a,c)=>{var m,d,f;if(c===l-1)if(i.children.has(a)){let u=i.children.get(a);u.posts&&(u.total+=1,u.posts.push(r))}else(m=i.children)==null||m.set(a,{total:1,posts:[r]});else if((d=i.children)!=null&&d.has(a)){let u=i.children.get(a);u.total+=1,i=u}else{let u={total:1,children:new Map};(f=i.children)==null||f.set(a,u),i=u}})}else{let l=r.categories;if(o.children.has(l)){let i=o.children.get(l);i.total+=1,i.posts.push(r)}else o.children.set(l,{total:1,posts:[r]})}else n.total+=1,n.posts.push(r)}),n.total===0&&((s=o.children)==null||s.delete("Uncategorized")),t){let r=o.children.get(t);return r?{total:r==null?void 0:r.total,children:new Map([[t,r]])}:(console.warn(`Do not have category: ${t}`),o)}else return o}var _tinycolor = require('@ctrl/tinycolor');function Jt(t={primary:"#0078E7"}){let e=W(),o=new (0, _tinycolor.TinyColor)("#999999"),n=new (0, _tinycolor.TinyColor)(t.primary);return{tags:e,getTagStyle:r=>{let l=Array.from(e).map(([d,f])=>f.count),i=Math.max(...l),a=Math.min(...l),c=i-a,m=(r-a)/c;return{"--yun-tag-color":o.mix(n,m*100).toString(),fontSize:`${m*36+12}px`}}}}function W(){let t=h(),e=new Map;return t.value.forEach(o=>{if(o.tags){let n;typeof o.tags=="string"?n=[o.tags]:n=o.tags,n.forEach(s=>{if(e.has(s)){let r=e.get(s);e.set(s,_chunkV3BMKLEWjs.b.call(void 0, _chunkV3BMKLEWjs.a.call(void 0, {},r),{count:r.count+1}))}else e.set(s,{count:1})})}}),e}var _core = require('@vueuse/core');function ee(){let t=_vuerouter.useRoute.call(void 0, );return _vue.computed.call(void 0, ()=>t.meta.frontmatter)}function oe(){let t=g(),e=_vuerouter.useRoute.call(void 0, );return _vue.computed.call(void 0, ()=>((t.value.url.endsWith("/")?t.value.url.slice(0,-1):t.value.url)||_core.isClient&&window.location.origin)+e.path)}var _head = require('@vueuse/head');function se(){_head.useHead.call(void 0, {link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css"}]})}function me(t){let e=_vue.ref.call(void 0, !1),{top:o}=_core.useElementBounding.call(void 0, t);return _core.useIntersectionObserver.call(void 0, t,([{isIntersecting:s}])=>{e.value=s}),{show:()=>{e.value||window.scrollTo(0,o.value)}}}var Q=_core.useDark.call(void 0, ),de= exports.toggleDark =_core.useToggle.call(void 0, Q);function xe(t){let e=_vuerouter.useRoute.call(void 0, );return _vue.computed.call(void 0, ()=>e.meta.layout===t)}function Te(){_head.useHead.call(void 0, {link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"}]}),_core.useScriptTag.call(void 0, "https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js",()=>{_core.useScriptTag.call(void 0, "https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js")})}function Le(t={offset:100}){if(!_core.isClient)return{percentage:_vue.ref.call(void 0, 0),show:_vue.ref.call(void 0, !1)};let{y:e}=_core.useWindowScroll.call(void 0, ),o=_vue.computed.call(void 0, ()=>e.value/(document.body.scrollHeight-window.innerHeight)),n=_vue.computed.call(void 0, ()=>e.value>t.offset);return{percentage:o,show:n}}function Ae(){_head.useHead.call(void 0, {script:[{src:"https://static.codepen.io/assets/embed/ei.js",async:!0}]})}function Ve(t,e){let o=at(n,200);function n(){let i=[].slice.call(document.querySelectorAll(".va-toc a.toc-link-item")),a=[].slice.call(document.querySelectorAll("main .header-anchor")).filter(c=>i.some(m=>m.hash===c.hash));for(let c=0;c<a.length;c++){let m=a[c],d=a[c+1],[f,u]=it(c,m,d);if(f){history.replaceState(null,document.title,u||" "),r(u);return}}}let s=null;function r(i){l(s);let a=s=i==null?null:t.value.querySelector(`.va-toc a[href="${i}"]`);e.value&&(a?(a.classList.add("active"),e.value.style.opacity="1",e.value.style.top=`${a.offsetTop+2}px`):(e.value.style.opacity="0",e.value.style.top="54px"))}function l(i){i&&i.classList.remove("active")}_vue.onMounted.call(void 0, ()=>{requestAnimationFrame(n),window.addEventListener("scroll",o)}),_vue.onUnmounted.call(void 0, ()=>{window.removeEventListener("scroll",o)})}function H(t){return t.parentElement.offsetTop-50}function it(t,e,o){let n=window.scrollY;return t===0&&n===0?[!0,null]:n<H(e)?[!1,null]:!o||n<H(o)?[!0,decodeURIComponent(e.hash)]:[!1,null]}function at(t,e){let o,n=!1;return()=>{o&&clearTimeout(o),n?o=setTimeout(t,e):(t(),n=!0,setTimeout(()=>{n=!1},e))}}function Ie(t={}){let e=_vuerouter.useRoute.call(void 0, ),{locale:o}=_vuei18n.useI18n.call(void 0, );function n(s={}){if(!_core.isClient)return;let r={el:".comment #tcomment",lang:o.value,path:e.path},l=Object.assign(r,s);return window.twikoo.init(l)}_core.useScriptTag.call(void 0, "//cdn.jsdelivr.net/npm/twikoo@1.5.1/dist/twikoo.all.min.js",()=>{n(t)})}function _e(t={}){_head.useHead.call(void 0, {link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css"}]});let e=_vuerouter.useRoute.call(void 0, ),{locale:o}=_vuei18n.useI18n.call(void 0, ),n;function s(r={}){if(!_core.isClient)return;let l={el:".comment #waline",lang:o.value,dark:"html.dark",emoji:["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/bilibili","https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/qq","https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],path:e.path},i=Object.assign(l,r);return window.Waline.init(i)}return _core.useScriptTag.call(void 0, "//cdn.jsdelivr.net/npm/@waline/client/dist/waline.js",()=>{n=s(t)}),_vue.watch.call(void 0, ()=>e.path,r=>{!n||n.update({path:r})}),_vue.watch.call(void 0, o,r=>{!n||n.update({lang:r})}),_vue.onUnmounted.call(void 0, ()=>{!n||n.destroy()}),n}exports.defaultValaxyConfig = _chunkV3BMKLEWjs.f; exports.formatDate = Et; exports.initConfig = Ct; exports.isDark = Q; exports.isParentCategory = Yt; exports.random = Pt; exports.sortByDate = y; exports.toggleDark = de; exports.useActiveSidebarLinks = Ve; exports.useAplayer = Te; exports.useBackToTop = Le; exports.useCategory = $t; exports.useCodePen = Ae; exports.useConfig = g; exports.useFrontmatter = ee; exports.useFullUrl = oe; exports.useInvisibleElement = me; exports.useKatex = se; exports.useLayout = xe; exports.usePageList = qt; exports.usePostList = h; exports.usePostProperty = zt; exports.usePostTitle = Ut; exports.usePrevNext = Bt; exports.useTag = W; exports.useTags = Jt; exports.useThemeConfig = P; exports.useTwikoo = Ie; exports.useWaline = _e; exports.valaxyConfigRef = T; exports.valaxyConfigSymbol = U; exports.wrap = q; exports.wrapTable = bt;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkU5OMNIOKjs = require('./chunk-U5OMNIOK.js');var _config = require('@valaxyjs/config'); var _config2 = _interopRequireDefault(_config);var _context = require('@valaxyjs/context'); var _context2 = _interopRequireDefault(_context);var _vue = require('vue');function h(t){let e=JSON.parse(t);return import.meta.env.DEV?_vue.readonly.call(void 0, e):e}var I=Symbol("valaxy:config"),P= exports.valaxyConfigRef =_vue.shallowRef.call(void 0, h(_config2.default)),j= exports.valaxyContextRef =_vue.shallowRef.call(void 0, h(_context2.default));import.meta.hot&&(import.meta.hot.accept("/@valaxyjs/config",t=>{P.value=h(t.default)}),import.meta.hot.accept("/@valaxyjs/context",t=>{j.value=h(t.default)}));function Et(){return _vue.computed.call(void 0, ()=>P.value)}function Mt(){return _vue.computed.call(void 0, ()=>j.value)}function v(){let t=_vue.inject.call(void 0, I);if(!t)throw new Error("[Valaxy] config not properly injected in app");return t}function y(){let t=v();return _vue.computed.call(void 0, ()=>t.value.themeConfig)}var _vuerouter = require('vue-router');var _vuei18n = require('vue-i18n');function St(t,e){return Math.random()*(e-t)+t}function N(t,e){let o=document.createElement("div");o.className=e,t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),o.appendChild(t)}var Dt=(t=document)=>{t.querySelectorAll("table").forEach(e=>{let o=document.createElement("div");o.className="table-container",N(e,"table-container")})};function Ht(t,e){let o,n=!1;return()=>{o&&clearTimeout(o),n?o=setTimeout(t,e):(t(),n=!0,setTimeout(()=>{n=!1},e))}}var _dayjs = require('dayjs'); var _dayjs2 = _interopRequireDefault(_dayjs);function Ut(t,e="YYYY-MM-DD"){return _dayjs2.default.call(void 0, t).format(e)}function C(t,e=!0){return t.sort((o,n)=>{let i=+new Date(o.date||""),r=+new Date(n.date||"");return e?r-i:i-r})}var Ft=t=>{let{locale:e}=_vuei18n.useI18n.call(void 0, );return _vue.computed.call(void 0, ()=>{let o=e.value==="zh-CN"?"zh":e.value;return t.value[`title_${o}`]||t.value.title})};function g(t={}){let e=_vuerouter.useRouter.call(void 0, );return _vue.computed.call(void 0, ()=>{let o=e.getRoutes().filter(r=>r.path.startsWith("/posts")&&r.meta.frontmatter&&r.meta.frontmatter.date).filter(r=>!r.path.endsWith(".html")).filter(r=>!t.type||r.meta.frontmatter.type===t.type).map(r=>Object.assign({path:r.path,excerpt:r.meta.excerpt},r.meta.frontmatter)),n=C(o.filter(r=>r.top)).sort((r,a)=>a.top-r.top),i=C(o.filter(r=>!r.top));return n.concat(i)})}function Kt(){let t=_vuerouter.useRouter.call(void 0, );return _vue.computed.call(void 0, ()=>t.getRoutes().map(o=>Object.assign({path:o.path,excerpt:o.meta.excerpt},o.meta.frontmatter)))}function _t(t){let e=_vuerouter.useRoute.call(void 0, ),o=_vue.computed.call(void 0, ()=>t||e.path),n=g(),i=_vue.computed.call(void 0, ()=>{let s=-1;return n.value.find((l,u)=>l.path===o.value?(s=u,!0):!1),s}),r=_vue.computed.call(void 0, ()=>i.value-1>=0?n.value[i.value-1]:null),a=_vue.computed.call(void 0, ()=>i.value+1<n.value.length?n.value[i.value+1]:null);return[r,a]}function Jt(t){if(!t)return{color:"",icon:"",styles:{}};let e=y();t in e.value.types||(t="link");let o=e.value.types[t].color,n=e.value.types[t].icon,i=_vue.computed.call(void 0, ()=>({"--card-c-primary":t&&o}));return{color:o,icon:n,styles:i}}var Zt=t=>t.children;function te(t,e=[]){var i;e.length||(e=_vue.unref.call(void 0, g()));let o={total:e.length,children:new Map([["Uncategorized",{total:0,posts:[]}]])},n=o.children.get("Uncategorized");if(e.forEach(r=>{if(r.categories)if(Array.isArray(r.categories)){let a=r.categories.length,s=o;r.categories.forEach((l,u)=>{var m,d,p;if(u===a-1)if(s.children.has(l)){let c=s.children.get(l);c.posts&&(c.total+=1,c.posts.push(r))}else(m=s.children)==null||m.set(l,{total:1,posts:[r]});else if((d=s.children)!=null&&d.has(l)){let c=s.children.get(l);c.total+=1,s=c}else{let c={total:1,children:new Map};(p=s.children)==null||p.set(l,c),s=c}})}else{let a=r.categories;if(o.children.has(a)){let s=o.children.get(a);s.total+=1,s.posts.push(r)}else o.children.set(a,{total:1,posts:[r]})}else n.total+=1,n.posts.push(r)}),n.total===0&&((i=o.children)==null||i.delete("Uncategorized")),t){let r=o.children.get(t);return r?{total:r==null?void 0:r.total,children:new Map([[t,r]])}:(console.warn(`Do not have category: ${t}`),o)}else return o}var _tinycolor = require('@ctrl/tinycolor');function ne(t={primary:"#0078E7"}){let e=J(),o=new (0, _tinycolor.TinyColor)("#999999"),n=new (0, _tinycolor.TinyColor)(t.primary);return{tags:e,getTagStyle:r=>{let a=Array.from(e).map(([d,p])=>p.count),s=Math.max(...a),l=Math.min(...a),u=s-l,m=(r-l)/u;return{"--yun-tag-color":o.mix(n,m*100).toString(),fontSize:`${m*36+12}px`}}}}function J(){let t=g(),e=new Map;return t.value.forEach(o=>{if(o.tags){let n;typeof o.tags=="string"?n=[o.tags]:n=o.tags,n.forEach(i=>{if(e.has(i)){let r=e.get(i);e.set(i,_chunkU5OMNIOKjs.b.call(void 0, _chunkU5OMNIOKjs.a.call(void 0, {},r),{count:r.count+1}))}else e.set(i,{count:1})})}}),e}var _core = require('@vueuse/core');function R(){let t=_vuerouter.useRoute.call(void 0, );return _vue.computed.call(void 0, ()=>t.meta.frontmatter)}function ce(){let t=v(),e=_vuerouter.useRoute.call(void 0, );return _vue.computed.call(void 0, ()=>((t.value.url.endsWith("/")?t.value.url.slice(0,-1):t.value.url)||_core.isClient&&window.location.origin)+e.path)}function de(t){let e=_vue.ref.call(void 0, !1),{top:o}=_core.useElementBounding.call(void 0, t);return _core.useIntersectionObserver.call(void 0, t,([{isIntersecting:i}])=>{e.value=i}),{show:()=>{e.value||window.scrollTo(0,o.value)}}}var ot=_core.useDark.call(void 0, ),ye= exports.toggleDark =_core.useToggle.call(void 0, ot);function Te(t){let e=_vuerouter.useRoute.call(void 0, );return _vue.computed.call(void 0, ()=>e.meta.layout===t)}var _head = require('@vueuse/head');function je(){_head.useHead.call(void 0, {link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"}]}),_core.useScriptTag.call(void 0, "https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js",()=>{_core.useScriptTag.call(void 0, "https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js")})}function Me(t={offset:100}){if(!_core.isClient)return{percentage:_vue.ref.call(void 0, 0),show:_vue.ref.call(void 0, !1)};let{y:e}=_core.useWindowScroll.call(void 0, ),o=_vue.computed.call(void 0, ()=>e.value/(document.body.scrollHeight-window.innerHeight)),n=_vue.computed.call(void 0, ()=>e.value>t.offset);return{percentage:o,show:n}}function De(){_head.useHead.call(void 0, {script:[{src:"https://static.codepen.io/assets/embed/ei.js",async:!0}]})}var _utils = require('@antfu/utils');function V(t,e){if(Array.isArray(t))return t;e=_utils.ensurePrefix.call(void 0, "/",e);for(let o in t)if(e.startsWith(_utils.ensurePrefix.call(void 0, "/",o)))return t[o];return[]}function $e(){let t=_vuerouter.useRoute.call(void 0, ),e=R(),o=y(),n=_vue.ref.call(void 0, !1),i=_vue.computed.call(void 0, ()=>{let u=o.value.sidebar,m=t.path;return u?V(u,m):[]}),r=_vue.computed.call(void 0, ()=>e.value.sidebar!==!1);function a(){n.value=!0}function s(){n.value=!1}function l(){n.value?s():a()}return{isOpen:n,sidebar:i,hasSidebar:r,open:a,close:s,toggle:l}}function Fe(t,e){let o=dt(n,200);function n(){let s=[].slice.call(document.querySelectorAll(".va-toc a.toc-link-item")),l=[].slice.call(document.querySelectorAll("main .header-anchor")).filter(u=>s.some(m=>m.hash===u.hash));for(let u=0;u<l.length;u++){let m=l[u],d=l[u+1],[p,c]=pt(u,m,d);if(p){history.replaceState(null,document.title,c||" "),r(c);return}}}let i=null;function r(s){a(i);let l=i=s==null?null:t.value.querySelector(`.va-toc a[href="${s}"]`);e.value&&(l?(l.classList.add("active"),e.value.style.opacity="1",e.value.style.top=`${l.offsetTop+2}px`):(e.value.style.opacity="0",e.value.style.top="54px"))}function a(s){s&&s.classList.remove("active")}_vue.onMounted.call(void 0, ()=>{requestAnimationFrame(n),window.addEventListener("scroll",o)}),_vue.onUnmounted.call(void 0, ()=>{window.removeEventListener("scroll",o)})}function O(t){return t.parentElement.offsetTop-50}function pt(t,e,o){let n=window.scrollY;return t===0&&n===0?[!0,null]:n<O(e)?[!1,null]:!o||n<O(o)?[!0,decodeURIComponent(e.hash)]:[!1,null]}function dt(t,e){let o,n=!1;return()=>{o&&clearTimeout(o),n?o=setTimeout(t,e):(t(),n=!0,setTimeout(()=>{n=!1},e))}}function Qe(t={}){let e=_vuerouter.useRoute.call(void 0, ),{locale:o}=_vuei18n.useI18n.call(void 0, );function n(i={}){if(!_core.isClient)return;let r={el:".comment #tcomment",lang:o.value,path:e.path},a=Object.assign(r,i);return window.twikoo.init(a)}_core.useScriptTag.call(void 0, "//cdn.jsdelivr.net/npm/twikoo@1.5.1/dist/twikoo.all.min.js",()=>{n(t)})}function no(t={}){_head.useHead.call(void 0, {link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css"}]});let e=_vuerouter.useRoute.call(void 0, ),{locale:o}=_vuei18n.useI18n.call(void 0, ),n;function i(r={}){if(!_core.isClient)return;let a={el:".comment #waline",lang:o.value,dark:"html.dark",emoji:["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/bilibili","https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/qq","https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],path:e.path},s=Object.assign(a,r);return window.Waline.init(s)}return _core.useScriptTag.call(void 0, "//cdn.jsdelivr.net/npm/@waline/client/dist/waline.js",()=>{n=i(t)}),_vue.watch.call(void 0, ()=>e.path,r=>{!n||n.update({path:r})}),_vue.watch.call(void 0, o,r=>{!n||n.update({lang:r})}),_vue.onUnmounted.call(void 0, ()=>{!n||n.destroy()}),n}function Eo(t){return t}function Mo(t){return t}exports.defineConfig = Eo; exports.defineConfigWithTheme = Mo; exports.formatDate = Ut; exports.initConfig = Et; exports.initContext = Mt; exports.isDark = ot; exports.isParentCategory = Zt; exports.random = St; exports.sortByDate = C; exports.throttleAndDebounce = Ht; exports.toggleDark = ye; exports.useActiveSidebarLinks = Fe; exports.useAplayer = je; exports.useBackToTop = Me; exports.useCategory = te; exports.useCodePen = De; exports.useConfig = v; exports.useFrontmatter = R; exports.useFullUrl = ce; exports.useInvisibleElement = de; exports.useLayout = Te; exports.usePageList = Kt; exports.usePostList = g; exports.usePostProperty = Jt; exports.usePostTitle = Ft; exports.usePrevNext = _t; exports.useSidebar = $e; exports.useTag = J; exports.useTags = ne; exports.useThemeConfig = y; exports.useTwikoo = Qe; exports.useWaline = no; exports.valaxyConfigRef = P; exports.valaxyConfigSymbol = I; exports.valaxyContextRef = j; exports.wrap = N; exports.wrapTable = Dt;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as T,b as w}from"./chunk-EAN2KU6W.mjs";import Y from"@valaxyjs/config";import B from"@valaxyjs/context";import{computed as x,inject as q,readonly as z,shallowRef as b}from"vue";function h(t){let e=JSON.parse(t);return import.meta.env.DEV?z(e):e}var I=Symbol("valaxy:config"),P=b(h(Y)),j=b(h(B));import.meta.hot&&(import.meta.hot.accept("/@valaxyjs/config",t=>{P.value=h(t.default)}),import.meta.hot.accept("/@valaxyjs/context",t=>{j.value=h(t.default)}));function Et(){return x(()=>P.value)}function Mt(){return x(()=>j.value)}function v(){let t=q(I);if(!t)throw new Error("[Valaxy] config not properly injected in app");return t}function y(){let t=v();return x(()=>t.value.themeConfig)}import{unref as _}from"vue";import{computed as f}from"vue";import{useRoute as F,useRouter as A}from"vue-router";import{useI18n as K}from"vue-i18n";function St(t,e){return Math.random()*(e-t)+t}function N(t,e){let o=document.createElement("div");o.className=e,t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),o.appendChild(t)}var Dt=(t=document)=>{t.querySelectorAll("table").forEach(e=>{let o=document.createElement("div");o.className="table-container",N(e,"table-container")})};function Ht(t,e){let o,n=!1;return()=>{o&&clearTimeout(o),n?o=setTimeout(t,e):(t(),n=!0,setTimeout(()=>{n=!1},e))}}import $ from"dayjs";function Ut(t,e="YYYY-MM-DD"){return $(t).format(e)}function C(t,e=!0){return t.sort((o,n)=>{let i=+new Date(o.date||""),r=+new Date(n.date||"");return e?r-i:i-r})}var Ft=t=>{let{locale:e}=K();return f(()=>{let o=e.value==="zh-CN"?"zh":e.value;return t.value[`title_${o}`]||t.value.title})};function g(t={}){let e=A();return f(()=>{let o=e.getRoutes().filter(r=>r.path.startsWith("/posts")&&r.meta.frontmatter&&r.meta.frontmatter.date).filter(r=>!r.path.endsWith(".html")).filter(r=>!t.type||r.meta.frontmatter.type===t.type).map(r=>Object.assign({path:r.path,excerpt:r.meta.excerpt},r.meta.frontmatter)),n=C(o.filter(r=>r.top)).sort((r,a)=>a.top-r.top),i=C(o.filter(r=>!r.top));return n.concat(i)})}function Kt(){let t=A();return f(()=>t.getRoutes().map(o=>Object.assign({path:o.path,excerpt:o.meta.excerpt},o.meta.frontmatter)))}function _t(t){let e=F(),o=f(()=>t||e.path),n=g(),i=f(()=>{let s=-1;return n.value.find((l,u)=>l.path===o.value?(s=u,!0):!1),s}),r=f(()=>i.value-1>=0?n.value[i.value-1]:null),a=f(()=>i.value+1<n.value.length?n.value[i.value+1]:null);return[r,a]}function Jt(t){if(!t)return{color:"",icon:"",styles:{}};let e=y();t in e.value.types||(t="link");let o=e.value.types[t].color,n=e.value.types[t].icon,i=f(()=>({"--card-c-primary":t&&o}));return{color:o,icon:n,styles:i}}var Zt=t=>t.children;function te(t,e=[]){var i;e.length||(e=_(g()));let o={total:e.length,children:new Map([["Uncategorized",{total:0,posts:[]}]])},n=o.children.get("Uncategorized");if(e.forEach(r=>{if(r.categories)if(Array.isArray(r.categories)){let a=r.categories.length,s=o;r.categories.forEach((l,u)=>{var m,d,p;if(u===a-1)if(s.children.has(l)){let c=s.children.get(l);c.posts&&(c.total+=1,c.posts.push(r))}else(m=s.children)==null||m.set(l,{total:1,posts:[r]});else if((d=s.children)!=null&&d.has(l)){let c=s.children.get(l);c.total+=1,s=c}else{let c={total:1,children:new Map};(p=s.children)==null||p.set(l,c),s=c}})}else{let a=r.categories;if(o.children.has(a)){let s=o.children.get(a);s.total+=1,s.posts.push(r)}else o.children.set(a,{total:1,posts:[r]})}else n.total+=1,n.posts.push(r)}),n.total===0&&((i=o.children)==null||i.delete("Uncategorized")),t){let r=o.children.get(t);return r?{total:r==null?void 0:r.total,children:new Map([[t,r]])}:(console.warn(`Do not have category: ${t}`),o)}else return o}import{TinyColor as L}from"@ctrl/tinycolor";function ne(t={primary:"#0078E7"}){let e=J(),o=new L("#999999"),n=new L(t.primary);return{tags:e,getTagStyle:r=>{let a=Array.from(e).map(([d,p])=>p.count),s=Math.max(...a),l=Math.min(...a),u=s-l,m=(r-l)/u;return{"--yun-tag-color":o.mix(n,m*100).toString(),fontSize:`${m*36+12}px`}}}}function J(){let t=g(),e=new Map;return t.value.forEach(o=>{if(o.tags){let n;typeof o.tags=="string"?n=[o.tags]:n=o.tags,n.forEach(i=>{if(e.has(i)){let r=e.get(i);e.set(i,w(T({},r),{count:r.count+1}))}else e.set(i,{count:1})})}}),e}import{useRoute as E}from"vue-router";import{computed as M}from"vue";import{isClient as G}from"@vueuse/core";function R(){let t=E();return M(()=>t.meta.frontmatter)}function ce(){let t=v(),e=E();return M(()=>((t.value.url.endsWith("/")?t.value.url.slice(0,-1):t.value.url)||G&&window.location.origin)+e.path)}import{useElementBounding as Q,useIntersectionObserver as X}from"@vueuse/core";import{ref as Z}from"vue";function de(t){let e=Z(!1),{top:o}=Q(t);return X(t,([{isIntersecting:i}])=>{e.value=i}),{show:()=>{e.value||window.scrollTo(0,o.value)}}}import{useDark as tt,useToggle as et}from"@vueuse/core";var ot=tt(),ye=et(ot);import{computed as rt}from"vue";import{useRoute as nt}from"vue-router";function Te(t){let e=nt();return rt(()=>e.meta.layout===t)}import{useScriptTag as S}from"@vueuse/core";import{useHead as it}from"@vueuse/head";function je(){it({link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"}]}),S("https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js",()=>{S("https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js")})}import{isClient as st,useWindowScroll as at}from"@vueuse/core";import{computed as D,ref as H}from"vue";function Me(t={offset:100}){if(!st)return{percentage:H(0),show:H(!1)};let{y:e}=at(),o=D(()=>e.value/(document.body.scrollHeight-window.innerHeight)),n=D(()=>e.value>t.offset);return{percentage:o,show:n}}import{useHead as lt}from"@vueuse/head";function De(){lt({script:[{src:"https://static.codepen.io/assets/embed/ei.js",async:!0}]})}import{computed as U,onMounted as ut,onUnmounted as ct,ref as mt}from"vue";import{useRoute as ft}from"vue-router";import{ensurePrefix as k}from"@antfu/utils";function V(t,e){if(Array.isArray(t))return t;e=k("/",e);for(let o in t)if(e.startsWith(k("/",o)))return t[o];return[]}function $e(){let t=ft(),e=R(),o=y(),n=mt(!1),i=U(()=>{let u=o.value.sidebar,m=t.path;return u?V(u,m):[]}),r=U(()=>e.value.sidebar!==!1);function a(){n.value=!0}function s(){n.value=!1}function l(){n.value?s():a()}return{isOpen:n,sidebar:i,hasSidebar:r,open:a,close:s,toggle:l}}function Fe(t,e){let o=dt(n,200);function n(){let s=[].slice.call(document.querySelectorAll(".va-toc a.toc-link-item")),l=[].slice.call(document.querySelectorAll("main .header-anchor")).filter(u=>s.some(m=>m.hash===u.hash));for(let u=0;u<l.length;u++){let m=l[u],d=l[u+1],[p,c]=pt(u,m,d);if(p){history.replaceState(null,document.title,c||" "),r(c);return}}}let i=null;function r(s){a(i);let l=i=s==null?null:t.value.querySelector(`.va-toc a[href="${s}"]`);e.value&&(l?(l.classList.add("active"),e.value.style.opacity="1",e.value.style.top=`${l.offsetTop+2}px`):(e.value.style.opacity="0",e.value.style.top="54px"))}function a(s){s&&s.classList.remove("active")}ut(()=>{requestAnimationFrame(n),window.addEventListener("scroll",o)}),ct(()=>{window.removeEventListener("scroll",o)})}function O(t){return t.parentElement.offsetTop-50}function pt(t,e,o){let n=window.scrollY;return t===0&&n===0?[!0,null]:n<O(e)?[!1,null]:!o||n<O(o)?[!0,decodeURIComponent(e.hash)]:[!1,null]}function dt(t,e){let o,n=!1;return()=>{o&&clearTimeout(o),n?o=setTimeout(t,e):(t(),n=!0,setTimeout(()=>{n=!1},e))}}import{isClient as gt,useScriptTag as ht}from"@vueuse/core";import{useI18n as yt}from"vue-i18n";import{useRoute as xt}from"vue-router";function Qe(t={}){let e=xt(),{locale:o}=yt();function n(i={}){if(!gt)return;let r={el:".comment #tcomment",lang:o.value,path:e.path},a=Object.assign(r,i);return window.twikoo.init(a)}ht("//cdn.jsdelivr.net/npm/twikoo@1.5.1/dist/twikoo.all.min.js",()=>{n(t)})}import{isClient as vt,useScriptTag as Ct}from"@vueuse/core";import{useHead as Tt}from"@vueuse/head";import{onUnmounted as wt,watch as W}from"vue";import{useI18n as bt}from"vue-i18n";import{useRoute as Pt}from"vue-router";function no(t={}){Tt({link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css"}]});let e=Pt(),{locale:o}=bt(),n;function i(r={}){if(!vt)return;let a={el:".comment #waline",lang:o.value,dark:"html.dark",emoji:["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/bilibili","https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/qq","https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],path:e.path},s=Object.assign(a,r);return window.Waline.init(s)}return Ct("//cdn.jsdelivr.net/npm/@waline/client/dist/waline.js",()=>{n=i(t)}),W(()=>e.path,r=>{!n||n.update({path:r})}),W(o,r=>{!n||n.update({lang:r})}),wt(()=>{!n||n.destroy()}),n}function Eo(t){return t}function Mo(t){return t}export{Eo as defineConfig,Mo as defineConfigWithTheme,Ut as formatDate,Et as initConfig,Mt as initContext,ot as isDark,Zt as isParentCategory,St as random,C as sortByDate,Ht as throttleAndDebounce,ye as toggleDark,Fe as useActiveSidebarLinks,je as useAplayer,Me as useBackToTop,te as useCategory,De as useCodePen,v as useConfig,R as useFrontmatter,ce as useFullUrl,de as useInvisibleElement,Te as useLayout,Kt as usePageList,g as usePostList,Jt as usePostProperty,Ft as usePostTitle,_t as usePrevNext,$e as useSidebar,J as useTag,ne as useTags,y as useThemeConfig,Qe as useTwikoo,no as useWaline,P as valaxyConfigRef,I as valaxyConfigSymbol,j as valaxyContextRef,N as wrap,Dt as wrapTable};
|