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.
Files changed (64) 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/ValaxyMd.vue +34 -27
  7. package/client/components/ValaxyToc.vue +3 -3
  8. package/client/composables/copy-code.ts +92 -0
  9. package/client/composables/outline.ts +168 -0
  10. package/client/composables/sidebar.ts +46 -1
  11. package/client/config.ts +30 -7
  12. package/client/main.ts +4 -1
  13. package/client/modules/valaxy.ts +19 -7
  14. package/client/shims.d.ts +6 -1
  15. package/client/styles/common/code.scss +191 -167
  16. package/client/styles/common/markdown.scss +0 -2
  17. package/client/styles/css-vars.scss +30 -7
  18. package/client/styles/palette.scss +21 -2
  19. package/client/styles/vars.scss +32 -18
  20. package/client/utils/helper.ts +22 -0
  21. package/client/utils/sidebar.ts +26 -0
  22. package/config/index.ts +18 -0
  23. package/dist/chunk-23IW567G.mjs +40 -0
  24. package/dist/chunk-YUC5WP5Y.js +40 -0
  25. package/dist/{config-7bd43d41.d.ts → config-112ac884.d.ts} +15 -4
  26. package/dist/index.d.ts +361 -0
  27. package/dist/index.js +1 -0
  28. package/dist/index.mjs +1 -0
  29. package/dist/node/cli.js +7 -11
  30. package/dist/node/cli.mjs +7 -11
  31. package/dist/node/index.d.ts +3 -2
  32. package/dist/node/index.js +1 -1
  33. package/dist/node/index.mjs +1 -1
  34. package/index.ts +3 -0
  35. package/node/config.ts +9 -23
  36. package/node/markdown/highlight.ts +27 -39
  37. package/node/markdown/index.ts +30 -16
  38. package/node/markdown/markdown-it/highlightLines.ts +1 -1
  39. package/node/markdown/markdownToVue.ts +275 -0
  40. package/node/options.ts +16 -0
  41. package/node/plugins/extendConfig.ts +4 -3
  42. package/node/plugins/index.ts +104 -7
  43. package/node/plugins/preset.ts +8 -8
  44. package/node/rss.ts +1 -1
  45. package/node/shims.d.ts +0 -5
  46. package/node/utils/getGitTimestamp.ts +13 -0
  47. package/node/utils/index.ts +11 -0
  48. package/package.json +20 -9
  49. package/shared/index.ts +1 -0
  50. package/tsup.config.ts +5 -3
  51. package/types/config.ts +7 -4
  52. package/types/data.ts +31 -0
  53. package/types/index.ts +1 -0
  54. package/types/posts.ts +1 -1
  55. package/dist/chunk-RSQONJW3.mjs +0 -86
  56. package/dist/chunk-XQIGHIAX.js +0 -86
  57. package/dist/client/index.d.ts +0 -188
  58. package/dist/client/index.js +0 -1
  59. package/dist/client/index.mjs +0 -1
  60. package/dist/posts-32f55e33.d.ts +0 -117
  61. package/dist/types/index.d.ts +0 -8
  62. package/dist/types/index.js +0 -1
  63. package/index.d.ts +0 -3
  64. package/node/plugins/markdown.ts +0 -54
@@ -1,188 +0,0 @@
1
- import * as vue from 'vue';
2
- import { InjectionKey, ComputedRef, Ref, StyleValue } from 'vue';
3
- import { V as ValaxyConfig, a as ValaxyThemeConfig } from '../config-7bd43d41.js';
4
- import { ThemeConfig } from 'valaxy-theme-yun';
5
- import { P as Post } from '../posts-32f55e33.js';
6
- import 'type-fest';
7
- import 'unocss/vite';
8
- import 'vite-plugin-md';
9
- import 'markdown-it';
10
- import 'markdown-it-anchor';
11
- import 'katex';
12
-
13
- declare const valaxyConfigSymbol: InjectionKey<ComputedRef<ValaxyConfig<ThemeConfig>>>;
14
- declare const valaxyConfigRef: vue.ShallowRef<ValaxyConfig<ValaxyThemeConfig>>;
15
- declare function initConfig(): ComputedRef<ValaxyConfig<ValaxyThemeConfig>>;
16
- declare function useConfig(): ComputedRef<ValaxyConfig<ThemeConfig>>;
17
- /**
18
- * getThemeConfig
19
- * @returns
20
- */
21
- declare function useThemeConfig(): ComputedRef<ThemeConfig & {
22
- pkg: {
23
- [key: string]: any;
24
- name: string;
25
- version: string;
26
- homepage?: string | undefined;
27
- };
28
- }>;
29
-
30
- interface BaseCategory {
31
- total: number;
32
- }
33
- interface ParentCategory extends BaseCategory {
34
- children: Categories;
35
- }
36
- interface PostCategory extends BaseCategory {
37
- posts: Post[];
38
- }
39
- declare type Category = ParentCategory | PostCategory;
40
- declare type Categories = Map<string, Category>;
41
- declare const isParentCategory: (category: any) => category is ParentCategory;
42
- /**
43
- * get categories from posts
44
- * @returns
45
- */
46
- declare function useCategory(category?: string, posts?: Post[]): ParentCategory;
47
-
48
- declare const usePostTitle: (post: Ref<Post>) => vue.ComputedRef<any>;
49
- /**
50
- * get post list
51
- * todo: use vue provide/inject to global
52
- * @param params
53
- * @returns
54
- */
55
- declare function usePostList(params?: {
56
- type?: string;
57
- }): vue.ComputedRef<Post[]>;
58
- /**
59
- * get all page
60
- * @returns
61
- */
62
- declare function usePageList(): vue.ComputedRef<any[]>;
63
- /**
64
- * get prev and next post
65
- * @param path
66
- * @returns
67
- */
68
- declare function usePrevNext(path?: string): vue.ComputedRef<Post | null>[];
69
- /**
70
- * get type card property
71
- * todo: test reactive
72
- */
73
- declare function usePostProperty(type?: string): {
74
- color: string;
75
- icon: string;
76
- styles: {};
77
- } | {
78
- color: string;
79
- icon: string;
80
- styles: vue.ComputedRef<StyleValue>;
81
- };
82
-
83
- declare type Tags = Map<string, {
84
- count: number;
85
- }>;
86
- /**
87
- * get utils about tags
88
- */
89
- declare function useTags(options?: {
90
- /**
91
- * Primary Color
92
- */
93
- primary: string;
94
- }): {
95
- tags: Tags;
96
- getTagStyle: (count: number) => {
97
- '--yun-tag-color': string;
98
- fontSize: string;
99
- };
100
- };
101
- /**
102
- * get tag map
103
- * @returns
104
- */
105
- declare function useTag(): Tags;
106
-
107
- declare function useFrontmatter(): vue.ComputedRef<Post>;
108
- /**
109
- * get full url
110
- */
111
- declare function useFullUrl(): vue.ComputedRef<string>;
112
-
113
- /**
114
- * trigger show invisible element
115
- * @param target
116
- * @returns
117
- */
118
- declare function useInvisibleElement(target: Ref<HTMLElement>): {
119
- show: () => void;
120
- };
121
-
122
- declare const isDark: vue.WritableComputedRef<boolean>;
123
- declare const toggleDark: (value?: boolean | undefined) => boolean;
124
-
125
- declare function useLayout(layout: string): vue.ComputedRef<boolean>;
126
-
127
- /**
128
- * use MetingJS and Aplayer
129
- * https://github.com/MoePlayer/APlayer
130
- * https://github.com/metowolf/MetingJS
131
- */
132
- declare function useAplayer(): void;
133
-
134
- /**
135
- * You can use href="#" to back to top
136
- * @description 你可以使用它来编写自己的 backToTop
137
- */
138
- declare function useBackToTop(options?: {
139
- /**
140
- * show backToTop button, when height > offset
141
- */
142
- offset: number;
143
- }): {
144
- percentage: vue.Ref<number>;
145
- show: vue.Ref<boolean>;
146
- } | {
147
- percentage: vue.ComputedRef<number>;
148
- show: vue.ComputedRef<boolean>;
149
- };
150
-
151
- declare function useCodePen(): void;
152
-
153
- declare function useActiveSidebarLinks(container: Ref<HTMLElement>, marker: Ref<HTMLElement>): void;
154
-
155
- declare function useTwikoo(options?: {}): void;
156
-
157
- declare function useWaline(options?: {}): any;
158
-
159
- /**
160
- * 生成介于 min 与 max 之间的随机数
161
- * @returns
162
- */
163
- declare function random(min: number, max: number): number;
164
- /**
165
- * wrap node
166
- * @param className
167
- */
168
- declare function wrap(el: HTMLElement, className: string): void;
169
- /**
170
- * 包裹表格,添加 class 以控制 table 样式
171
- */
172
- declare const wrapTable: (container?: HTMLElement | Document) => void;
173
-
174
- /**
175
- * use dayjs format date
176
- * @param date
177
- * @param template
178
- * @returns
179
- */
180
- declare function formatDate(date: string | number | Date, template?: string): string;
181
- /**
182
- * sort posts by date
183
- * @param posts
184
- * @param desc
185
- */
186
- declare function sortByDate(posts: Post[], desc?: boolean): Post[];
187
-
188
- export { BaseCategory, Categories, Category, ParentCategory, PostCategory, Tags, formatDate, initConfig, isDark, isParentCategory, random, sortByDate, toggleDark, useActiveSidebarLinks, useAplayer, useBackToTop, useCategory, useCodePen, useConfig, useFrontmatter, useFullUrl, useInvisibleElement, useLayout, usePageList, usePostList, usePostProperty, usePostTitle, usePrevNext, useTag, useTags, useThemeConfig, useTwikoo, useWaline, valaxyConfigRef, valaxyConfigSymbol, wrap, wrapTable };
@@ -1 +0,0 @@
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 _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 xt(){return _vue.computed.call(void 0, ()=>T.value)}function h(){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=h();return _vue.computed.call(void 0, ()=>t.value.themeConfig)}var _vuerouter = require('vue-router');var _vuei18n = require('vue-i18n');function Ct(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 Tt=(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 jt(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 Ot=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=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 Vt(){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 Ut(t){let e=_vuerouter.useRoute.call(void 0, ),o=_vue.computed.call(void 0, ()=>t||e.path),n=g(),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 qt(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 Nt=t=>t.children;function Wt(t,e=[]){var s;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 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 Kt(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=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(s=>{if(e.has(s)){let r=e.get(s);e.set(s,_chunkU5OMNIOKjs.b.call(void 0, _chunkU5OMNIOKjs.a.call(void 0, {},r),{count:r.count+1}))}else e.set(s,{count:1})})}}),e}var _core = require('@vueuse/core');function Zt(){let t=_vuerouter.useRoute.call(void 0, );return _vue.computed.call(void 0, ()=>t.meta.frontmatter)}function te(){let t=h(),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 ne(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 G=_core.useDark.call(void 0, ),ae= exports.toggleDark =_core.useToggle.call(void 0, G);function me(t){let e=_vuerouter.useRoute.call(void 0, );return _vue.computed.call(void 0, ()=>e.meta.layout===t)}var _head = require('@vueuse/head');function ge(){_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 xe(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 Te(){_head.useHead.call(void 0, {script:[{src:"https://static.codepen.io/assets/embed/ei.js",async:!0}]})}function Ae(t,e){let o=it(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]=st(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 S(t){return t.parentElement.offsetTop-50}function st(t,e,o){let n=window.scrollY;return t===0&&n===0?[!0,null]:n<S(e)?[!1,null]:!o||n<S(o)?[!0,decodeURIComponent(e.hash)]:[!1,null]}function it(t,e){let o,n=!1;return()=>{o&&clearTimeout(o),n?o=setTimeout(t,e):(t(),n=!0,setTimeout(()=>{n=!1},e))}}function De(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 Ie(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.formatDate = jt; exports.initConfig = xt; exports.isDark = G; exports.isParentCategory = Nt; exports.random = Ct; exports.sortByDate = y; exports.toggleDark = ae; exports.useActiveSidebarLinks = Ae; exports.useAplayer = ge; exports.useBackToTop = xe; exports.useCategory = Wt; exports.useCodePen = Te; exports.useConfig = h; exports.useFrontmatter = Zt; exports.useFullUrl = te; exports.useInvisibleElement = ne; exports.useLayout = me; exports.usePageList = Vt; exports.usePostList = g; exports.usePostProperty = qt; exports.usePostTitle = Ot; exports.usePrevNext = Ut; exports.useTag = W; exports.useTags = Kt; exports.useThemeConfig = P; exports.useTwikoo = De; exports.useWaline = Ie; exports.valaxyConfigRef = T; exports.valaxyConfigSymbol = U; exports.wrap = q; exports.wrapTable = Tt;
@@ -1 +0,0 @@
1
- import{a as v,b as x}from"../chunk-EAN2KU6W.mjs";import k from"@valaxyjs/config";import{computed as w,inject as D,readonly as O,shallowRef as V}from"vue";function C(t){let e=JSON.parse(t);return import.meta.env.DEV?O(e):e}var U=Symbol("valaxy:config"),T=V(C(k));import.meta.hot&&import.meta.hot.accept("/@valaxyjs/config",t=>{T.value=C(t.default)});function xt(){return w(()=>T.value)}function h(){let t=D(U);if(!t)throw new Error("[Valaxy] config not properly injected in qpp");return t}function P(){let t=h();return w(()=>t.value.themeConfig)}import{unref as N}from"vue";import{computed as p}from"vue";import{useRoute as z,useRouter as b}from"vue-router";import{useI18n as I}from"vue-i18n";function Ct(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 Tt=(t=document)=>{t.querySelectorAll("table").forEach(e=>{let o=document.createElement("div");o.className="table-container",q(e,"table-container")})};import B from"dayjs";function jt(t,e="YYYY-MM-DD"){return B(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 Ot=t=>{let{locale:e}=I();return p(()=>{let o=e.value==="zh-CN"?"zh":e.value;return t.value[`title_${o}`]||t.value.title})};function g(t={}){let e=b();return p(()=>{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 Vt(){let t=b();return p(()=>t.getRoutes().map(o=>Object.assign({path:o.path,excerpt:o.meta.excerpt},o.meta.frontmatter)))}function Ut(t){let e=z(),o=p(()=>t||e.path),n=g(),s=p(()=>{let i=-1;return n.value.find((a,c)=>a.path===o.value?(i=c,!0):!1),i}),r=p(()=>s.value-1>=0?n.value[s.value-1]:null),l=p(()=>s.value+1<n.value.length?n.value[s.value+1]:null);return[r,l]}function qt(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=p(()=>({"--card-c-primary":t&&o}));return{color:o,icon:n,styles:s}}var Nt=t=>t.children;function Wt(t,e=[]){var s;e.length||(e=N(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 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}import{TinyColor as j}from"@ctrl/tinycolor";function Kt(t={primary:"#0078E7"}){let e=W(),o=new j("#999999"),n=new j(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=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(s=>{if(e.has(s)){let r=e.get(s);e.set(s,x(v({},r),{count:r.count+1}))}else e.set(s,{count:1})})}}),e}import{useRoute as L}from"vue-router";import{computed as E}from"vue";import{isClient as Y}from"@vueuse/core";function Zt(){let t=L();return E(()=>t.meta.frontmatter)}function te(){let t=h(),e=L();return E(()=>((t.value.url.endsWith("/")?t.value.url.slice(0,-1):t.value.url)||Y&&window.location.origin)+e.path)}import{useElementBounding as $,useIntersectionObserver as F}from"@vueuse/core";import{ref as K}from"vue";function ne(t){let e=K(!1),{top:o}=$(t);return F(t,([{isIntersecting:s}])=>{e.value=s}),{show:()=>{e.value||window.scrollTo(0,o.value)}}}import{useDark as _,useToggle as J}from"@vueuse/core";var G=_(),ae=J(G);import{computed as Q}from"vue";import{useRoute as X}from"vue-router";function me(t){let e=X();return Q(()=>e.meta.layout===t)}import{useScriptTag as M}from"@vueuse/core";import{useHead as Z}from"@vueuse/head";function ge(){Z({link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"}]}),M("https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js",()=>{M("https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js")})}import{isClient as tt,useWindowScroll as et}from"@vueuse/core";import{computed as A,ref as R}from"vue";function xe(t={offset:100}){if(!tt)return{percentage:R(0),show:R(!1)};let{y:e}=et(),o=A(()=>e.value/(document.body.scrollHeight-window.innerHeight)),n=A(()=>e.value>t.offset);return{percentage:o,show:n}}import{useHead as ot}from"@vueuse/head";function Te(){ot({script:[{src:"https://static.codepen.io/assets/embed/ei.js",async:!0}]})}import{onMounted as rt,onUnmounted as nt}from"vue";function Ae(t,e){let o=it(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]=st(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")}rt(()=>{requestAnimationFrame(n),window.addEventListener("scroll",o)}),nt(()=>{window.removeEventListener("scroll",o)})}function S(t){return t.parentElement.offsetTop-50}function st(t,e,o){let n=window.scrollY;return t===0&&n===0?[!0,null]:n<S(e)?[!1,null]:!o||n<S(o)?[!0,decodeURIComponent(e.hash)]:[!1,null]}function it(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 at,useScriptTag as lt}from"@vueuse/core";import{useI18n as ct}from"vue-i18n";import{useRoute as ut}from"vue-router";function De(t={}){let e=ut(),{locale:o}=ct();function n(s={}){if(!at)return;let r={el:".comment #tcomment",lang:o.value,path:e.path},l=Object.assign(r,s);return window.twikoo.init(l)}lt("//cdn.jsdelivr.net/npm/twikoo@1.5.1/dist/twikoo.all.min.js",()=>{n(t)})}import{isClient as mt,useScriptTag as pt}from"@vueuse/core";import{useHead as ft}from"@vueuse/head";import{onUnmounted as dt,watch as H}from"vue";import{useI18n as gt}from"vue-i18n";import{useRoute as ht}from"vue-router";function Ie(t={}){ft({link:[{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css"}]});let e=ht(),{locale:o}=gt(),n;function s(r={}){if(!mt)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 pt("//cdn.jsdelivr.net/npm/@waline/client/dist/waline.js",()=>{n=s(t)}),H(()=>e.path,r=>{!n||n.update({path:r})}),H(o,r=>{!n||n.update({lang:r})}),dt(()=>{!n||n.destroy()}),n}export{jt as formatDate,xt as initConfig,G as isDark,Nt as isParentCategory,Ct as random,y as sortByDate,ae as toggleDark,Ae as useActiveSidebarLinks,ge as useAplayer,xe as useBackToTop,Wt as useCategory,Te as useCodePen,h as useConfig,Zt as useFrontmatter,te as useFullUrl,ne as useInvisibleElement,me as useLayout,Vt as usePageList,g as usePostList,qt as usePostProperty,Ot as usePostTitle,Ut as usePrevNext,W as useTag,Kt as useTags,P as useThemeConfig,De as useTwikoo,Ie as useWaline,T as valaxyConfigRef,U as valaxyConfigSymbol,q as wrap,Tt as wrapTable};
@@ -1,117 +0,0 @@
1
- interface Post extends Record<string, any> {
2
- /**
3
- * Path of post
4
- * route.path
5
- * @description 路径
6
- */
7
- path?: string;
8
- /**
9
- * Title
10
- * @description 文章标题
11
- */
12
- title?: string;
13
- date?: string | number | Date;
14
- /**
15
- * Updated Time
16
- */
17
- updated?: string | number | Date;
18
- lang?: string;
19
- /**
20
- * TODO
21
- * Read Time
22
- * @description 阅读时长
23
- */
24
- duration?: string;
25
- /**
26
- * post card type, can be bilibili/yuque/...
27
- */
28
- type?: string;
29
- /**
30
- * override url, and jump directly
31
- */
32
- url?: string;
33
- /**
34
- * @description 摘要
35
- */
36
- excerpt?: string;
37
- /**
38
- * Display sponsor info
39
- * @description 是否开启赞助
40
- */
41
- sponsor?: boolean;
42
- /**
43
- * Copyright
44
- * @description 是否显示文章底部版权信息
45
- */
46
- copyright?: boolean;
47
- /**
48
- * Category
49
- * @description 分类,若为数组,则按顺序代表多层文件夹
50
- */
51
- categories?: string | string[];
52
- /**
53
- * Tags
54
- * @description 标签,可以有多个
55
- */
56
- tags?: string[];
57
- /**
58
- * display prev next
59
- * @description 是否显示前一篇、后一篇导航
60
- */
61
- nav?: boolean;
62
- /**
63
- * icon before title
64
- */
65
- icon?: string;
66
- /**
67
- * title color
68
- */
69
- color?: string;
70
- /**
71
- * display comment
72
- */
73
- comment?: boolean;
74
- /**
75
- * post is end
76
- * @description 是否完结,将在末尾添加衬线字体 Q.E.D.
77
- */
78
- end?: boolean;
79
- /**
80
- * use aplayer
81
- */
82
- aplayer?: boolean;
83
- /**
84
- * use katex
85
- */
86
- katex?: boolean;
87
- /**
88
- * use codepen
89
- */
90
- codepen?: boolean;
91
- /**
92
- * 置顶
93
- */
94
- top?: number;
95
- /**
96
- * display toc
97
- * @description 是否显示目录
98
- */
99
- toc?: boolean;
100
- /**
101
- * is draft
102
- * @description 是否为草稿
103
- */
104
- draft?: boolean;
105
- /**
106
- * cover
107
- * @description 封面图片
108
- */
109
- cover?: string;
110
- /**
111
- * enable markdown-body class
112
- * @description 是否启用默认的 markdown 样式
113
- */
114
- markdown: boolean;
115
- }
116
-
117
- export { Post as P };
@@ -1,8 +0,0 @@
1
- export { A as AlgoliaSearchOptions, S as SocialLink, U as UserConfig, V as ValaxyConfig, a as ValaxyThemeConfig, b as ViteMdOptions } from '../config-7bd43d41.js';
2
- export { P as Post } from '../posts-32f55e33.js';
3
- import 'type-fest';
4
- import 'unocss/vite';
5
- import 'vite-plugin-md';
6
- import 'markdown-it';
7
- import 'markdown-it-anchor';
8
- import 'katex';
@@ -1 +0,0 @@
1
- "use strict";
package/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- // export * from './dist/client'
2
- export * from './dist/node'
3
- export * from './dist/types'
@@ -1,54 +0,0 @@
1
- import Markdown from 'vite-plugin-md'
2
-
3
- import type { Plugin } from 'vite'
4
- import type { ResolvedValaxyOptions } from '../options'
5
-
6
- import { setupMarkdownPlugins } from '../markdown'
7
- import { checkMd } from '../markdown/check'
8
-
9
- export const excerpt_separator = '<!-- more -->'
10
-
11
- // https://github.com/antfu/vite-plugin-md
12
-
13
- export function createMarkdownPlugin(options: ResolvedValaxyOptions): Plugin[] {
14
- const mdOptions = options.config.markdownIt
15
-
16
- return [Markdown({
17
- wrapperComponent: 'ValaxyMd',
18
- wrapperClasses: '',
19
-
20
- headEnabled: true,
21
- frontmatter: true,
22
- excerpt: excerpt_separator,
23
-
24
- markdownItSetup(md) {
25
- if (mdOptions.config)
26
- mdOptions.config(md)
27
-
28
- setupMarkdownPlugins(md, mdOptions)
29
- },
30
-
31
- transforms: {
32
- before: (code, id) => {
33
- checkMd(code, id)
34
-
35
- code.replace('{%', '\{\%')
36
- code.replace('%}', '\%\}')
37
- return code
38
- },
39
- },
40
- ...options.config.markdown,
41
- }), {
42
- name: 'valaxy:md',
43
- handleHotUpdate(ctx) {
44
- const { file, server } = ctx
45
- // send headers
46
- if (file.endsWith('.md')) {
47
- server.ws.send({
48
- type: 'custom',
49
- event: 'valaxy:md-update',
50
- })
51
- }
52
- },
53
- }]
54
- }