valaxy 0.5.0 → 0.6.0

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.
Files changed (55) hide show
  1. package/README.md +0 -4
  2. package/{dist/types/index.mjs → client/app/data.ts} +0 -0
  3. package/client/components/PostCard.vue +4 -2
  4. package/client/components/ValaxyBg.vue +1 -1
  5. package/client/components/ValaxyFooter.vue +1 -1
  6. package/client/components/ValaxyToc.vue +3 -3
  7. package/client/composables/outline.ts +181 -0
  8. package/client/composables/sidebar.ts +58 -1
  9. package/client/config.ts +30 -7
  10. package/client/main.ts +4 -1
  11. package/client/modules/valaxy.ts +33 -8
  12. package/client/shims.d.ts +6 -1
  13. package/client/styles/palette.scss +6 -2
  14. package/client/utils/helper.ts +22 -0
  15. package/client/utils/sidebar.ts +26 -0
  16. package/config/index.ts +18 -0
  17. package/dist/chunk-CP3UCJ2D.js +34 -0
  18. package/dist/chunk-HCVZ2UUO.mjs +34 -0
  19. package/dist/{config-7bd43d41.d.ts → config-ad23e743.d.ts} +6 -4
  20. package/dist/index.d.ts +363 -0
  21. package/dist/index.js +1 -0
  22. package/dist/index.mjs +1 -0
  23. package/dist/node/cli.js +7 -11
  24. package/dist/node/cli.mjs +7 -11
  25. package/dist/node/index.d.ts +2 -2
  26. package/dist/node/index.js +1 -1
  27. package/dist/node/index.mjs +1 -1
  28. package/index.ts +3 -0
  29. package/node/config.ts +9 -23
  30. package/node/markdown/index.ts +21 -13
  31. package/node/markdown/markdownToVue.ts +253 -0
  32. package/node/options.ts +16 -0
  33. package/node/plugins/extendConfig.ts +4 -3
  34. package/node/plugins/index.ts +103 -6
  35. package/node/plugins/preset.ts +6 -6
  36. package/node/rss.ts +1 -1
  37. package/node/utils/getGitTimestamp.ts +13 -0
  38. package/node/utils/index.ts +11 -0
  39. package/package.json +20 -7
  40. package/shared/index.ts +1 -0
  41. package/tsup.config.ts +5 -3
  42. package/types/config.ts +7 -4
  43. package/types/data.ts +31 -0
  44. package/types/index.ts +1 -0
  45. package/types/posts.ts +1 -1
  46. package/dist/chunk-RSQONJW3.mjs +0 -86
  47. package/dist/chunk-XQIGHIAX.js +0 -86
  48. package/dist/client/index.d.ts +0 -188
  49. package/dist/client/index.js +0 -1
  50. package/dist/client/index.mjs +0 -1
  51. package/dist/posts-32f55e33.d.ts +0 -117
  52. package/dist/types/index.d.ts +0 -8
  53. package/dist/types/index.js +0 -1
  54. package/index.d.ts +0 -3
  55. package/node/plugins/markdown.ts +0 -54
@@ -0,0 +1,363 @@
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-ad23e743.js';
4
+ export { A as AlgoliaSearchOptions, S as SocialLink, U as UserConfig, V as ValaxyConfig, a as ValaxyThemeConfig } from './config-ad23e743.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 'markdown-it-anchor';
12
+ import 'katex';
13
+
14
+ interface Post extends Record<string, any> {
15
+ /**
16
+ * Path of post
17
+ * route.path
18
+ * @description 路径
19
+ */
20
+ path?: string;
21
+ /**
22
+ * Title
23
+ * @description 文章标题
24
+ */
25
+ title?: string;
26
+ date?: string | number | Date;
27
+ /**
28
+ * Updated Time
29
+ */
30
+ updated?: string | number | Date;
31
+ lang?: string;
32
+ /**
33
+ * TODO
34
+ * Read Time
35
+ * @description 阅读时长
36
+ */
37
+ duration?: string;
38
+ /**
39
+ * post card type, can be bilibili/yuque/...
40
+ */
41
+ type?: string;
42
+ /**
43
+ * override url, and jump directly
44
+ */
45
+ url?: string;
46
+ /**
47
+ * @description 摘要
48
+ */
49
+ excerpt?: string;
50
+ /**
51
+ * Display sponsor info
52
+ * @description 是否开启赞助
53
+ */
54
+ sponsor?: boolean;
55
+ /**
56
+ * Copyright
57
+ * @description 是否显示文章底部版权信息
58
+ */
59
+ copyright?: boolean;
60
+ /**
61
+ * Category
62
+ * @description 分类,若为数组,则按顺序代表多层文件夹
63
+ */
64
+ categories?: string | string[];
65
+ /**
66
+ * Tags
67
+ * @description 标签,可以有多个
68
+ */
69
+ tags?: string[];
70
+ /**
71
+ * display prev next
72
+ * @description 是否显示前一篇、后一篇导航
73
+ */
74
+ nav?: boolean;
75
+ /**
76
+ * icon before title
77
+ */
78
+ icon?: string;
79
+ /**
80
+ * title color
81
+ */
82
+ color?: string;
83
+ /**
84
+ * display comment
85
+ */
86
+ comment?: boolean;
87
+ /**
88
+ * post is end
89
+ * @description 是否完结,将在末尾添加衬线字体 Q.E.D.
90
+ */
91
+ end?: boolean;
92
+ /**
93
+ * use aplayer
94
+ */
95
+ aplayer?: boolean;
96
+ /**
97
+ * use katex
98
+ */
99
+ katex?: boolean;
100
+ /**
101
+ * use codepen
102
+ */
103
+ codepen?: boolean;
104
+ /**
105
+ * 置顶
106
+ */
107
+ top?: number;
108
+ /**
109
+ * display toc
110
+ * @description 是否显示目录
111
+ */
112
+ toc?: boolean;
113
+ /**
114
+ * is draft
115
+ * @description 是否为草稿
116
+ */
117
+ draft?: boolean;
118
+ /**
119
+ * cover
120
+ * @description 封面图片
121
+ */
122
+ cover?: string;
123
+ /**
124
+ * enable markdown-body class
125
+ * @description 是否启用默认的 markdown 样式
126
+ */
127
+ markdown?: boolean;
128
+ }
129
+
130
+ interface Header {
131
+ level: number;
132
+ title: string;
133
+ slug: string;
134
+ /**
135
+ * i18n
136
+ */
137
+ lang?: string;
138
+ }
139
+ interface PageData {
140
+ path: string;
141
+ relativePath: string;
142
+ title: string;
143
+ titleTemplate?: string;
144
+ description: string;
145
+ headers: Header[];
146
+ frontmatter: Post;
147
+ lastUpdated?: number;
148
+ }
149
+ interface PageDataPayload {
150
+ path: string;
151
+ pageData: PageData;
152
+ }
153
+ declare type HeadConfig = [string, Record<string, string>] | [string, Record<string, string>, string];
154
+
155
+ interface ValaxyContext {
156
+ userRoot: string;
157
+ }
158
+ declare const valaxyConfigSymbol: InjectionKey<ComputedRef<ValaxyConfig<ThemeConfig>>>;
159
+ declare const valaxyConfigRef: vue.ShallowRef<ValaxyConfig<ValaxyThemeConfig>>;
160
+ declare const valaxyContextRef: vue.ShallowRef<ValaxyContext>;
161
+ declare function initConfig(): ComputedRef<ValaxyConfig<ValaxyThemeConfig>>;
162
+ declare function initContext(): ComputedRef<ValaxyContext>;
163
+ declare function useConfig(): ComputedRef<ValaxyConfig<ThemeConfig>>;
164
+ /**
165
+ * getThemeConfig
166
+ * @returns
167
+ */
168
+ declare function useThemeConfig(): ComputedRef<ThemeConfig & {
169
+ pkg: {
170
+ [key: string]: any;
171
+ name: string;
172
+ version: string;
173
+ homepage?: string | undefined;
174
+ };
175
+ }>;
176
+ interface ValaxyData<T = any> {
177
+ page: Ref<PageData>;
178
+ theme: Ref<T>;
179
+ }
180
+
181
+ interface BaseCategory {
182
+ total: number;
183
+ }
184
+ interface ParentCategory extends BaseCategory {
185
+ children: Categories;
186
+ }
187
+ interface PostCategory extends BaseCategory {
188
+ posts: Post[];
189
+ }
190
+ declare type Category = ParentCategory | PostCategory;
191
+ declare type Categories = Map<string, Category>;
192
+ declare const isParentCategory: (category: any) => category is ParentCategory;
193
+ /**
194
+ * get categories from posts
195
+ * @returns
196
+ */
197
+ declare function useCategory(category?: string, posts?: Post[]): ParentCategory;
198
+
199
+ declare const usePostTitle: (post: Ref<Post>) => vue.ComputedRef<any>;
200
+ /**
201
+ * get post list
202
+ * todo: use vue provide/inject to global
203
+ * @param params
204
+ * @returns
205
+ */
206
+ declare function usePostList(params?: {
207
+ type?: string;
208
+ }): vue.ComputedRef<Post[]>;
209
+ /**
210
+ * get all page
211
+ * @returns
212
+ */
213
+ declare function usePageList(): vue.ComputedRef<({
214
+ path: string;
215
+ excerpt: unknown;
216
+ } & Post)[]>;
217
+ /**
218
+ * get prev and next post
219
+ * @param path
220
+ * @returns
221
+ */
222
+ declare function usePrevNext(path?: string): vue.ComputedRef<Post | null>[];
223
+ /**
224
+ * get type card property
225
+ * todo: test reactive
226
+ */
227
+ declare function usePostProperty(type?: string): {
228
+ color: string;
229
+ icon: string;
230
+ styles: {};
231
+ } | {
232
+ color: string;
233
+ icon: string;
234
+ styles: vue.ComputedRef<StyleValue>;
235
+ };
236
+
237
+ declare type Tags = Map<string, {
238
+ count: number;
239
+ }>;
240
+ /**
241
+ * get utils about tags
242
+ */
243
+ declare function useTags(options?: {
244
+ /**
245
+ * Primary Color
246
+ */
247
+ primary: string;
248
+ }): {
249
+ tags: Tags;
250
+ getTagStyle: (count: number) => {
251
+ '--yun-tag-color': string;
252
+ fontSize: string;
253
+ };
254
+ };
255
+ /**
256
+ * get tag map
257
+ * @returns
258
+ */
259
+ declare function useTag(): Tags;
260
+
261
+ declare function useFrontmatter(): vue.ComputedRef<Post>;
262
+ /**
263
+ * get full url
264
+ */
265
+ declare function useFullUrl(): vue.ComputedRef<string>;
266
+
267
+ /**
268
+ * trigger show invisible element
269
+ * @param target
270
+ * @returns
271
+ */
272
+ declare function useInvisibleElement(target: Ref<HTMLElement>): {
273
+ show: () => void;
274
+ };
275
+
276
+ declare const isDark: vue.WritableComputedRef<boolean>;
277
+ declare const toggleDark: (value?: boolean | undefined) => boolean;
278
+
279
+ declare function useLayout(layout: string): vue.ComputedRef<boolean>;
280
+
281
+ /**
282
+ * use MetingJS and Aplayer
283
+ * https://github.com/MoePlayer/APlayer
284
+ * https://github.com/metowolf/MetingJS
285
+ */
286
+ declare function useAplayer(): void;
287
+
288
+ /**
289
+ * You can use href="#" to back to top
290
+ * @description 你可以使用它来编写自己的 backToTop
291
+ */
292
+ declare function useBackToTop(options?: {
293
+ /**
294
+ * show backToTop button, when height > offset
295
+ */
296
+ offset: number;
297
+ }): {
298
+ percentage: vue.Ref<number>;
299
+ show: vue.Ref<boolean>;
300
+ } | {
301
+ percentage: vue.ComputedRef<number>;
302
+ show: vue.ComputedRef<boolean>;
303
+ };
304
+
305
+ declare function useCodePen(): void;
306
+
307
+ declare function useSidebar(): {
308
+ isOpen: Ref<boolean>;
309
+ sidebar: vue.ComputedRef<any>;
310
+ hasSidebar: vue.ComputedRef<boolean>;
311
+ open: () => void;
312
+ close: () => void;
313
+ toggle: () => void;
314
+ };
315
+ declare function useActiveSidebarLinks(container: Ref<HTMLElement>, marker: Ref<HTMLElement>): void;
316
+ declare function useOutline(): {
317
+ hasOutline: vue.ComputedRef<boolean>;
318
+ };
319
+
320
+ declare function useTwikoo(options?: {}): void;
321
+
322
+ declare function useWaline(options?: {}): any;
323
+
324
+ /**
325
+ * 生成介于 min 与 max 之间的随机数
326
+ * @returns
327
+ */
328
+ declare function random(min: number, max: number): number;
329
+ /**
330
+ * wrap node
331
+ * @param className
332
+ */
333
+ declare function wrap(el: HTMLElement, className: string): void;
334
+ /**
335
+ * 包裹表格,添加 class 以控制 table 样式
336
+ */
337
+ declare const wrapTable: (container?: HTMLElement | Document) => void;
338
+ declare function throttleAndDebounce(fn: () => void, delay: number): () => void;
339
+
340
+ /**
341
+ * use dayjs format date
342
+ * @param date
343
+ * @param template
344
+ * @returns
345
+ */
346
+ declare function formatDate(date: string | number | Date, template?: string): string;
347
+ /**
348
+ * sort posts by date
349
+ * @param posts
350
+ * @param desc
351
+ */
352
+ declare function sortByDate(posts: Post[], desc?: boolean): Post[];
353
+
354
+ /**
355
+ * Type config helper
356
+ */
357
+ declare function defineConfig(config: UserConfig<YunTheme.Config>): type_fest_source_partial_deep.PartialObjectDeep<ValaxyConfig<valaxy_theme_yun.ThemeConfig>>;
358
+ /**
359
+ * Type config helper for custom theme config
360
+ */
361
+ declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig<ThemeConfig>): type_fest_source_partial_deep.PartialObjectDeep<ValaxyConfig<ThemeConfig>>;
362
+
363
+ 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, useOutline, 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 N=Symbol("valaxy:config"),j= exports.valaxyConfigRef =_vue.shallowRef.call(void 0, h(_config2.default)),A= exports.valaxyContextRef =_vue.shallowRef.call(void 0, h(_context2.default));import.meta.hot&&(import.meta.hot.accept("/@valaxyjs/config",t=>{j.value=h(t.default)}),import.meta.hot.accept("/@valaxyjs/context",t=>{A.value=h(t.default)}));function Et(){return _vue.computed.call(void 0, ()=>j.value)}function Mt(){return _vue.computed.call(void 0, ()=>A.value)}function v(){let t=_vue.inject.call(void 0, N);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 $(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",$(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 Ot(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=G(),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 G(){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 S(){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 rt=_core.useDark.call(void 0, ),ye= exports.toggleDark =_core.useToggle.call(void 0, rt);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 O(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=S(),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?O(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 U(t){return t.parentElement.offsetTop-50}function pt(t,e,o){let n=window.scrollY;return t===0&&n===0?[!0,null]:n<U(e)?[!1,null]:!o||n<U(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 Ke(){let t=_vuerouter.useRoute.call(void 0, );return{hasOutline:_vue.computed.call(void 0, ()=>t.meta.headers.length>0)}}function Xe(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 io(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 Mo(t){return t}function Ro(t){return t}exports.defineConfig = Mo; exports.defineConfigWithTheme = Ro; exports.formatDate = Ot; exports.initConfig = Et; exports.initContext = Mt; exports.isDark = rt; 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 = S; exports.useFullUrl = ce; exports.useInvisibleElement = de; exports.useLayout = Te; exports.useOutline = Ke; exports.usePageList = Kt; exports.usePostList = g; exports.usePostProperty = Jt; exports.usePostTitle = Ft; exports.usePrevNext = _t; exports.useSidebar = $e; exports.useTag = G; exports.useTags = ne; exports.useThemeConfig = y; exports.useTwikoo = Xe; exports.useWaline = io; exports.valaxyConfigRef = j; exports.valaxyConfigSymbol = N; exports.valaxyContextRef = A; exports.wrap = $; exports.wrapTable = Dt;
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{a as w,b}from"./chunk-EAN2KU6W.mjs";import B from"@valaxyjs/config";import q from"@valaxyjs/context";import{computed as x,inject as z,readonly as I,shallowRef as P}from"vue";function h(t){let e=JSON.parse(t);return import.meta.env.DEV?I(e):e}var N=Symbol("valaxy:config"),j=P(h(B)),A=P(h(q));import.meta.hot&&(import.meta.hot.accept("/@valaxyjs/config",t=>{j.value=h(t.default)}),import.meta.hot.accept("/@valaxyjs/context",t=>{A.value=h(t.default)}));function Et(){return x(()=>j.value)}function Mt(){return x(()=>A.value)}function v(){let t=z(N);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 J}from"vue";import{computed as f}from"vue";import{useRoute as K,useRouter as L}from"vue-router";import{useI18n as _}from"vue-i18n";function St(t,e){return Math.random()*(e-t)+t}function $(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",$(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 F from"dayjs";function Ot(t,e="YYYY-MM-DD"){return F(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}=_();return f(()=>{let o=e.value==="zh-CN"?"zh":e.value;return t.value[`title_${o}`]||t.value.title})};function g(t={}){let e=L();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=L();return f(()=>t.getRoutes().map(o=>Object.assign({path:o.path,excerpt:o.meta.excerpt},o.meta.frontmatter)))}function _t(t){let e=K(),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=J(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 E}from"@ctrl/tinycolor";function ne(t={primary:"#0078E7"}){let e=G(),o=new E("#999999"),n=new E(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 G(){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,b(w({},r),{count:r.count+1}))}else e.set(i,{count:1})})}}),e}import{useRoute as M}from"vue-router";import{computed as R}from"vue";import{isClient as Q}from"@vueuse/core";function S(){let t=M();return R(()=>t.meta.frontmatter)}function ce(){let t=v(),e=M();return R(()=>((t.value.url.endsWith("/")?t.value.url.slice(0,-1):t.value.url)||Q&&window.location.origin)+e.path)}import{useElementBounding as X,useIntersectionObserver as Z}from"@vueuse/core";import{ref as tt}from"vue";function de(t){let e=tt(!1),{top:o}=X(t);return Z(t,([{isIntersecting:i}])=>{e.value=i}),{show:()=>{e.value||window.scrollTo(0,o.value)}}}import{useDark as et,useToggle as ot}from"@vueuse/core";var rt=et(),ye=ot(rt);import{computed as nt}from"vue";import{useRoute as it}from"vue-router";function Te(t){let e=it();return nt(()=>e.meta.layout===t)}import{useScriptTag as D}from"@vueuse/core";import{useHead as st}from"@vueuse/head";function je(){st({link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"}]}),D("https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js",()=>{D("https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js")})}import{isClient as at,useWindowScroll as lt}from"@vueuse/core";import{computed as H,ref as k}from"vue";function Me(t={offset:100}){if(!at)return{percentage:k(0),show:k(!1)};let{y:e}=lt(),o=H(()=>e.value/(document.body.scrollHeight-window.innerHeight)),n=H(()=>e.value>t.offset);return{percentage:o,show:n}}import{useHead as ut}from"@vueuse/head";function De(){ut({script:[{src:"https://static.codepen.io/assets/embed/ei.js",async:!0}]})}import{computed as T,onMounted as ct,onUnmounted as mt,ref as ft}from"vue";import{useRoute as W}from"vue-router";import{ensurePrefix as V}from"@antfu/utils";function O(t,e){if(Array.isArray(t))return t;e=V("/",e);for(let o in t)if(e.startsWith(V("/",o)))return t[o];return[]}function $e(){let t=W(),e=S(),o=y(),n=ft(!1),i=T(()=>{let u=o.value.sidebar,m=t.path;return u?O(u,m):[]}),r=T(()=>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")}ct(()=>{requestAnimationFrame(n),window.addEventListener("scroll",o)}),mt(()=>{window.removeEventListener("scroll",o)})}function U(t){return t.parentElement.offsetTop-50}function pt(t,e,o){let n=window.scrollY;return t===0&&n===0?[!0,null]:n<U(e)?[!1,null]:!o||n<U(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 Ke(){let t=W();return{hasOutline:T(()=>t.meta.headers.length>0)}}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 Xe(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 Y}from"vue";import{useI18n as bt}from"vue-i18n";import{useRoute as Pt}from"vue-router";function io(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)}),Y(()=>e.path,r=>{!n||n.update({path:r})}),Y(o,r=>{!n||n.update({lang:r})}),wt(()=>{!n||n.destroy()}),n}function Mo(t){return t}function Ro(t){return t}export{Mo as defineConfig,Ro as defineConfigWithTheme,Ot as formatDate,Et as initConfig,Mt as initContext,rt 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,S as useFrontmatter,ce as useFullUrl,de as useInvisibleElement,Te as useLayout,Ke as useOutline,Kt as usePageList,g as usePostList,Jt as usePostProperty,Ft as usePostTitle,_t as usePrevNext,$e as useSidebar,G as useTag,ne as useTags,y as useThemeConfig,Xe as useTwikoo,io as useWaline,j as valaxyConfigRef,N as valaxyConfigSymbol,A as valaxyContextRef,$ as wrap,Dt as wrapTable};