valaxy 0.5.0 → 0.6.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.
- package/README.md +0 -4
- package/{dist/types/index.mjs → client/app/data.ts} +0 -0
- package/client/components/PostCard.vue +4 -2
- package/client/components/ValaxyBg.vue +1 -1
- package/client/components/ValaxyFooter.vue +1 -1
- package/client/components/ValaxyMd.vue +34 -27
- package/client/components/ValaxyToc.vue +3 -3
- package/client/composables/copy-code.ts +92 -0
- package/client/composables/outline.ts +168 -0
- package/client/composables/sidebar.ts +46 -1
- package/client/config.ts +30 -7
- package/client/main.ts +4 -1
- package/client/modules/valaxy.ts +19 -7
- package/client/shims.d.ts +6 -1
- package/client/styles/common/code.scss +191 -167
- package/client/styles/common/markdown.scss +0 -2
- package/client/styles/css-vars.scss +30 -7
- package/client/styles/palette.scss +21 -2
- package/client/styles/vars.scss +32 -18
- package/client/utils/helper.ts +22 -0
- package/client/utils/sidebar.ts +26 -0
- package/config/index.ts +18 -0
- package/dist/chunk-23IW567G.mjs +40 -0
- package/dist/chunk-YUC5WP5Y.js +40 -0
- package/dist/{config-7bd43d41.d.ts → config-112ac884.d.ts} +15 -4
- package/dist/index.d.ts +361 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- 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/index.ts +3 -0
- package/node/config.ts +9 -23
- package/node/markdown/highlight.ts +27 -39
- package/node/markdown/index.ts +30 -16
- package/node/markdown/markdown-it/highlightLines.ts +1 -1
- package/node/markdown/markdownToVue.ts +275 -0
- package/node/options.ts +16 -0
- package/node/plugins/extendConfig.ts +4 -3
- package/node/plugins/index.ts +104 -7
- package/node/plugins/preset.ts +8 -8
- package/node/rss.ts +1 -1
- package/node/shims.d.ts +0 -5
- package/node/utils/getGitTimestamp.ts +13 -0
- package/node/utils/index.ts +11 -0
- package/package.json +20 -9
- package/shared/index.ts +1 -0
- package/tsup.config.ts +5 -3
- package/types/config.ts +7 -4
- package/types/data.ts +31 -0
- package/types/index.ts +1 -0
- package/types/posts.ts +1 -1
- package/dist/chunk-RSQONJW3.mjs +0 -86
- package/dist/chunk-XQIGHIAX.js +0 -86
- package/dist/client/index.d.ts +0 -188
- package/dist/client/index.js +0 -1
- package/dist/client/index.mjs +0 -1
- package/dist/posts-32f55e33.d.ts +0 -117
- package/dist/types/index.d.ts +0 -8
- package/dist/types/index.js +0 -1
- package/index.d.ts +0 -3
- package/node/plugins/markdown.ts +0 -54
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { InjectionKey, ComputedRef, Ref, StyleValue } from 'vue';
|
|
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';
|
|
8
|
+
import 'type-fest';
|
|
9
|
+
import 'unocss/vite';
|
|
10
|
+
import 'markdown-it';
|
|
11
|
+
import 'shiki';
|
|
12
|
+
import 'markdown-it-anchor';
|
|
13
|
+
import 'katex';
|
|
14
|
+
|
|
15
|
+
interface Post extends Record<string, any> {
|
|
16
|
+
/**
|
|
17
|
+
* Path of post
|
|
18
|
+
* route.path
|
|
19
|
+
* @description 路径
|
|
20
|
+
*/
|
|
21
|
+
path?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Title
|
|
24
|
+
* @description 文章标题
|
|
25
|
+
*/
|
|
26
|
+
title?: string;
|
|
27
|
+
date?: string | number | Date;
|
|
28
|
+
/**
|
|
29
|
+
* Updated Time
|
|
30
|
+
*/
|
|
31
|
+
updated?: string | number | Date;
|
|
32
|
+
lang?: string;
|
|
33
|
+
/**
|
|
34
|
+
* TODO
|
|
35
|
+
* Read Time
|
|
36
|
+
* @description 阅读时长
|
|
37
|
+
*/
|
|
38
|
+
duration?: string;
|
|
39
|
+
/**
|
|
40
|
+
* post card type, can be bilibili/yuque/...
|
|
41
|
+
*/
|
|
42
|
+
type?: string;
|
|
43
|
+
/**
|
|
44
|
+
* override url, and jump directly
|
|
45
|
+
*/
|
|
46
|
+
url?: string;
|
|
47
|
+
/**
|
|
48
|
+
* @description 摘要
|
|
49
|
+
*/
|
|
50
|
+
excerpt?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Display sponsor info
|
|
53
|
+
* @description 是否开启赞助
|
|
54
|
+
*/
|
|
55
|
+
sponsor?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Copyright
|
|
58
|
+
* @description 是否显示文章底部版权信息
|
|
59
|
+
*/
|
|
60
|
+
copyright?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Category
|
|
63
|
+
* @description 分类,若为数组,则按顺序代表多层文件夹
|
|
64
|
+
*/
|
|
65
|
+
categories?: string | string[];
|
|
66
|
+
/**
|
|
67
|
+
* Tags
|
|
68
|
+
* @description 标签,可以有多个
|
|
69
|
+
*/
|
|
70
|
+
tags?: string[];
|
|
71
|
+
/**
|
|
72
|
+
* display prev next
|
|
73
|
+
* @description 是否显示前一篇、后一篇导航
|
|
74
|
+
*/
|
|
75
|
+
nav?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* icon before title
|
|
78
|
+
*/
|
|
79
|
+
icon?: string;
|
|
80
|
+
/**
|
|
81
|
+
* title color
|
|
82
|
+
*/
|
|
83
|
+
color?: string;
|
|
84
|
+
/**
|
|
85
|
+
* display comment
|
|
86
|
+
*/
|
|
87
|
+
comment?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* post is end
|
|
90
|
+
* @description 是否完结,将在末尾添加衬线字体 Q.E.D.
|
|
91
|
+
*/
|
|
92
|
+
end?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* use aplayer
|
|
95
|
+
*/
|
|
96
|
+
aplayer?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* use katex
|
|
99
|
+
*/
|
|
100
|
+
katex?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* use codepen
|
|
103
|
+
*/
|
|
104
|
+
codepen?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* 置顶
|
|
107
|
+
*/
|
|
108
|
+
top?: number;
|
|
109
|
+
/**
|
|
110
|
+
* display toc
|
|
111
|
+
* @description 是否显示目录
|
|
112
|
+
*/
|
|
113
|
+
toc?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* is draft
|
|
116
|
+
* @description 是否为草稿
|
|
117
|
+
*/
|
|
118
|
+
draft?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* cover
|
|
121
|
+
* @description 封面图片
|
|
122
|
+
*/
|
|
123
|
+
cover?: string;
|
|
124
|
+
/**
|
|
125
|
+
* enable markdown-body class
|
|
126
|
+
* @description 是否启用默认的 markdown 样式
|
|
127
|
+
*/
|
|
128
|
+
markdown?: boolean;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface Header {
|
|
132
|
+
level: number;
|
|
133
|
+
title: string;
|
|
134
|
+
slug: string;
|
|
135
|
+
/**
|
|
136
|
+
* i18n
|
|
137
|
+
*/
|
|
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;
|
|
149
|
+
}
|
|
150
|
+
interface PageDataPayload {
|
|
151
|
+
path: string;
|
|
152
|
+
pageData: PageData;
|
|
153
|
+
}
|
|
154
|
+
declare type HeadConfig = [string, Record<string, string>] | [string, Record<string, string>, string];
|
|
155
|
+
|
|
156
|
+
interface ValaxyContext {
|
|
157
|
+
userRoot: string;
|
|
158
|
+
}
|
|
159
|
+
declare const valaxyConfigSymbol: InjectionKey<ComputedRef<ValaxyConfig<ThemeConfig>>>;
|
|
160
|
+
declare const valaxyConfigRef: vue.ShallowRef<ValaxyConfig<ValaxyThemeConfig>>;
|
|
161
|
+
declare const valaxyContextRef: vue.ShallowRef<ValaxyContext>;
|
|
162
|
+
declare function initConfig(): ComputedRef<ValaxyConfig<ValaxyThemeConfig>>;
|
|
163
|
+
declare function initContext(): ComputedRef<ValaxyContext>;
|
|
164
|
+
declare function useConfig(): ComputedRef<ValaxyConfig<ThemeConfig>>;
|
|
165
|
+
/**
|
|
166
|
+
* getThemeConfig
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
declare function useThemeConfig(): ComputedRef<ThemeConfig & {
|
|
170
|
+
pkg: {
|
|
171
|
+
[key: string]: any;
|
|
172
|
+
name: string;
|
|
173
|
+
version: string;
|
|
174
|
+
homepage?: string | undefined;
|
|
175
|
+
};
|
|
176
|
+
}>;
|
|
177
|
+
interface ValaxyData<T = any> {
|
|
178
|
+
page: Ref<PageData>;
|
|
179
|
+
theme: Ref<T>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface BaseCategory {
|
|
183
|
+
total: number;
|
|
184
|
+
}
|
|
185
|
+
interface ParentCategory extends BaseCategory {
|
|
186
|
+
children: Categories;
|
|
187
|
+
}
|
|
188
|
+
interface PostCategory extends BaseCategory {
|
|
189
|
+
posts: Post[];
|
|
190
|
+
}
|
|
191
|
+
declare type Category = ParentCategory | PostCategory;
|
|
192
|
+
declare type Categories = Map<string, Category>;
|
|
193
|
+
declare const isParentCategory: (category: any) => category is ParentCategory;
|
|
194
|
+
/**
|
|
195
|
+
* get categories from posts
|
|
196
|
+
* @returns
|
|
197
|
+
*/
|
|
198
|
+
declare function useCategory(category?: string, posts?: Post[]): ParentCategory;
|
|
199
|
+
|
|
200
|
+
declare const usePostTitle: (post: Ref<Post>) => vue.ComputedRef<any>;
|
|
201
|
+
/**
|
|
202
|
+
* get post list
|
|
203
|
+
* todo: use vue provide/inject to global
|
|
204
|
+
* @param params
|
|
205
|
+
* @returns
|
|
206
|
+
*/
|
|
207
|
+
declare function usePostList(params?: {
|
|
208
|
+
type?: string;
|
|
209
|
+
}): vue.ComputedRef<Post[]>;
|
|
210
|
+
/**
|
|
211
|
+
* get all page
|
|
212
|
+
* @returns
|
|
213
|
+
*/
|
|
214
|
+
declare function usePageList(): vue.ComputedRef<({
|
|
215
|
+
path: string;
|
|
216
|
+
excerpt: unknown;
|
|
217
|
+
} & Post)[]>;
|
|
218
|
+
/**
|
|
219
|
+
* get prev and next post
|
|
220
|
+
* @param path
|
|
221
|
+
* @returns
|
|
222
|
+
*/
|
|
223
|
+
declare function usePrevNext(path?: string): vue.ComputedRef<Post | null>[];
|
|
224
|
+
/**
|
|
225
|
+
* get type card property
|
|
226
|
+
* todo: test reactive
|
|
227
|
+
*/
|
|
228
|
+
declare function usePostProperty(type?: string): {
|
|
229
|
+
color: string;
|
|
230
|
+
icon: string;
|
|
231
|
+
styles: {};
|
|
232
|
+
} | {
|
|
233
|
+
color: string;
|
|
234
|
+
icon: string;
|
|
235
|
+
styles: vue.ComputedRef<StyleValue>;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
declare type Tags = Map<string, {
|
|
239
|
+
count: number;
|
|
240
|
+
}>;
|
|
241
|
+
/**
|
|
242
|
+
* get utils about tags
|
|
243
|
+
*/
|
|
244
|
+
declare function useTags(options?: {
|
|
245
|
+
/**
|
|
246
|
+
* Primary Color
|
|
247
|
+
*/
|
|
248
|
+
primary: string;
|
|
249
|
+
}): {
|
|
250
|
+
tags: Tags;
|
|
251
|
+
getTagStyle: (count: number) => {
|
|
252
|
+
'--yun-tag-color': string;
|
|
253
|
+
fontSize: string;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* get tag map
|
|
258
|
+
* @returns
|
|
259
|
+
*/
|
|
260
|
+
declare function useTag(): Tags;
|
|
261
|
+
|
|
262
|
+
declare function useFrontmatter(): vue.ComputedRef<Post>;
|
|
263
|
+
/**
|
|
264
|
+
* get full url
|
|
265
|
+
*/
|
|
266
|
+
declare function useFullUrl(): vue.ComputedRef<string>;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* trigger show invisible element
|
|
270
|
+
* @param target
|
|
271
|
+
* @returns
|
|
272
|
+
*/
|
|
273
|
+
declare function useInvisibleElement(target: Ref<HTMLElement>): {
|
|
274
|
+
show: () => void;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
declare const isDark: vue.WritableComputedRef<boolean>;
|
|
278
|
+
declare const toggleDark: (value?: boolean | undefined) => boolean;
|
|
279
|
+
|
|
280
|
+
declare function useLayout(layout: string): vue.ComputedRef<boolean>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* use MetingJS and Aplayer
|
|
284
|
+
* https://github.com/MoePlayer/APlayer
|
|
285
|
+
* https://github.com/metowolf/MetingJS
|
|
286
|
+
*/
|
|
287
|
+
declare function useAplayer(): void;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* You can use href="#" to back to top
|
|
291
|
+
* @description 你可以使用它来编写自己的 backToTop
|
|
292
|
+
*/
|
|
293
|
+
declare function useBackToTop(options?: {
|
|
294
|
+
/**
|
|
295
|
+
* show backToTop button, when height > offset
|
|
296
|
+
*/
|
|
297
|
+
offset: number;
|
|
298
|
+
}): {
|
|
299
|
+
percentage: vue.Ref<number>;
|
|
300
|
+
show: vue.Ref<boolean>;
|
|
301
|
+
} | {
|
|
302
|
+
percentage: vue.ComputedRef<number>;
|
|
303
|
+
show: vue.ComputedRef<boolean>;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
declare function useCodePen(): void;
|
|
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
|
+
};
|
|
316
|
+
declare function useActiveSidebarLinks(container: Ref<HTMLElement>, marker: Ref<HTMLElement>): void;
|
|
317
|
+
|
|
318
|
+
declare function useTwikoo(options?: {}): void;
|
|
319
|
+
|
|
320
|
+
declare function useWaline(options?: {}): any;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* 生成介于 min 与 max 之间的随机数
|
|
324
|
+
* @returns
|
|
325
|
+
*/
|
|
326
|
+
declare function random(min: number, max: number): number;
|
|
327
|
+
/**
|
|
328
|
+
* wrap node
|
|
329
|
+
* @param className
|
|
330
|
+
*/
|
|
331
|
+
declare function wrap(el: HTMLElement, className: string): void;
|
|
332
|
+
/**
|
|
333
|
+
* 包裹表格,添加 class 以控制 table 样式
|
|
334
|
+
*/
|
|
335
|
+
declare const wrapTable: (container?: HTMLElement | Document) => void;
|
|
336
|
+
declare function throttleAndDebounce(fn: () => void, delay: number): () => void;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* use dayjs format date
|
|
340
|
+
* @param date
|
|
341
|
+
* @param template
|
|
342
|
+
* @returns
|
|
343
|
+
*/
|
|
344
|
+
declare function formatDate(date: string | number | Date, template?: string): string;
|
|
345
|
+
/**
|
|
346
|
+
* sort posts by date
|
|
347
|
+
* @param posts
|
|
348
|
+
* @param desc
|
|
349
|
+
*/
|
|
350
|
+
declare function sortByDate(posts: Post[], desc?: boolean): Post[];
|
|
351
|
+
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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};
|