@ansidev-oss/vitepress-theme-ansidev 1.0.10 → 1.0.11

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 (45) hide show
  1. package/dist/client/Sharing-ZrU7YF-x.js +190 -0
  2. package/dist/client/Swetrix-CM1mbD6X.js +450 -0
  3. package/dist/client/{VPAlgoliaSearchBox-DXE-LCVf.js → VPAlgoliaSearchBox-BAhNuo7n.js} +1 -1
  4. package/dist/client/{VPCarbonAds-Czmm53YE.js → VPCarbonAds-CSK7KnIu.js} +1 -1
  5. package/dist/client/{VPLocalSearchBox-ihwA4uH-.js → VPLocalSearchBox-TYbANUkJ.js} +1 -1
  6. package/dist/client/composables/index.d.ts +1 -1
  7. package/dist/client/{index-CZCdwVUW.js → index-C43AnX3f.js} +1623 -1573
  8. package/dist/client/index-DuYWs0vj.js +265 -0
  9. package/dist/client/index.d.ts +2 -1
  10. package/dist/client/index.js +7 -2
  11. package/dist/client/plugins/medium-zoom/index.d.ts +14 -0
  12. package/dist/client/plugins/sharing/index.d.ts +59 -0
  13. package/dist/client/plugins/swetrix/index.d.ts +10 -0
  14. package/dist/client/styles.css +1 -1
  15. package/dist/client/types/index.d.ts +14 -1
  16. package/dist/node/composables/index.d.ts +3 -0
  17. package/dist/node/composables/markdown.d.ts +2 -0
  18. package/dist/node/composables/route.d.ts +15 -0
  19. package/dist/node/composables/slug.d.ts +7 -0
  20. package/dist/node/composables/types.d.ts +7 -0
  21. package/dist/node/composables.d.mts +4 -2
  22. package/dist/node/composables.mjs +4 -1
  23. package/dist/node/config.d.mts +90 -8
  24. package/dist/node/config.d.ts +45 -0
  25. package/dist/node/config.mjs +19 -10
  26. package/dist/shared/composables/index.d.ts +1 -0
  27. package/package.json +11 -3
  28. package/src/client/components/DonationWidget.vue +22 -0
  29. package/src/client/components/Footer.vue +12 -12
  30. package/src/client/components/SharingWidget.vue +19 -0
  31. package/src/client/composables/index.ts +1 -1
  32. package/src/client/index.ts +2 -8
  33. package/src/client/layouts/Layout.vue +48 -2
  34. package/src/client/plugins/medium-zoom/index.ts +30 -0
  35. package/src/client/plugins/sharing/components/Sharing.vue +81 -0
  36. package/src/client/plugins/sharing/components/SharingButton.vue +115 -0
  37. package/src/client/plugins/sharing/index.ts +76 -0
  38. package/src/client/plugins/swetrix/components/Swetrix.vue +43 -0
  39. package/src/client/plugins/swetrix/index.ts +11 -0
  40. package/src/client/types/index.ts +14 -1
  41. package/src/node/composables/slug.ts +3 -13
  42. package/src/node/config.ts +22 -13
  43. package/src/shared/composables/index.ts +1 -0
  44. /package/dist/{client/composables/slug.d.ts → shared/composables/useSlug.d.ts} +0 -0
  45. /package/src/{client/composables/slug.ts → shared/composables/useSlug.ts} +0 -0
@@ -0,0 +1,265 @@
1
+ var E = Object.assign || function(m) {
2
+ for (var t = 1; t < arguments.length; t++) {
3
+ var a = arguments[t];
4
+ for (var u in a)
5
+ Object.prototype.hasOwnProperty.call(a, u) && (m[u] = a[u]);
6
+ }
7
+ return m;
8
+ }, x = function(t) {
9
+ return t.tagName === "IMG";
10
+ }, de = function(t) {
11
+ return NodeList.prototype.isPrototypeOf(t);
12
+ }, A = function(t) {
13
+ return t && t.nodeType === 1;
14
+ }, U = function(t) {
15
+ var a = t.currentSrc || t.src;
16
+ return a.substr(-4).toLowerCase() === ".svg";
17
+ }, W = function(t) {
18
+ try {
19
+ return Array.isArray(t) ? t.filter(x) : de(t) ? [].slice.call(t).filter(x) : A(t) ? [t].filter(x) : typeof t == "string" ? [].slice.call(document.querySelectorAll(t)).filter(x) : [];
20
+ } catch {
21
+ throw new TypeError(`The provided selector is invalid.
22
+ Expects a CSS selector, a Node element, a NodeList or an array.
23
+ See: https://github.com/francoischalifour/medium-zoom`);
24
+ }
25
+ }, me = function(t) {
26
+ var a = document.createElement("div");
27
+ return a.classList.add("medium-zoom-overlay"), a.style.background = t, a;
28
+ }, le = function(t) {
29
+ var a = t.getBoundingClientRect(), u = a.top, g = a.left, N = a.width, I = a.height, h = t.cloneNode(), j = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0, C = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
30
+ return h.removeAttribute("id"), h.style.position = "absolute", h.style.top = u + j + "px", h.style.left = g + C + "px", h.style.width = N + "px", h.style.height = I + "px", h.style.transform = "", h;
31
+ }, L = function(t, a) {
32
+ var u = E({
33
+ bubbles: !1,
34
+ cancelable: !1,
35
+ detail: void 0
36
+ }, a);
37
+ if (typeof window.CustomEvent == "function")
38
+ return new CustomEvent(t, u);
39
+ var g = document.createEvent("CustomEvent");
40
+ return g.initCustomEvent(t, u.bubbles, u.cancelable, u.detail), g;
41
+ }, ue = function m(t) {
42
+ var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, u = window.Promise || function(o) {
43
+ function n() {
44
+ }
45
+ o(n, n);
46
+ }, g = function(o) {
47
+ var n = o.target;
48
+ if (n === S) {
49
+ z();
50
+ return;
51
+ }
52
+ v.indexOf(n) !== -1 && Z({ target: n });
53
+ }, N = function() {
54
+ if (!(b || !e.original)) {
55
+ var o = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
56
+ Math.abs(B - o) > i.scrollOffset && setTimeout(z, 150);
57
+ }
58
+ }, I = function(o) {
59
+ var n = o.key || o.keyCode;
60
+ (n === "Escape" || n === "Esc" || n === 27) && z();
61
+ }, h = function() {
62
+ var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = o;
63
+ if (o.background && (S.style.background = o.background), o.container && o.container instanceof Object && (n.container = E({}, i.container, o.container)), o.template) {
64
+ var d = A(o.template) ? o.template : document.querySelector(o.template);
65
+ n.template = d;
66
+ }
67
+ return i = E({}, i, n), v.forEach(function(l) {
68
+ l.dispatchEvent(L("medium-zoom:update", {
69
+ detail: { zoom: c }
70
+ }));
71
+ }), c;
72
+ }, j = function() {
73
+ var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
74
+ return m(E({}, i, o));
75
+ }, C = function() {
76
+ for (var o = arguments.length, n = Array(o), d = 0; d < o; d++)
77
+ n[d] = arguments[d];
78
+ var l = n.reduce(function(r, f) {
79
+ return [].concat(r, W(f));
80
+ }, []);
81
+ return l.filter(function(r) {
82
+ return v.indexOf(r) === -1;
83
+ }).forEach(function(r) {
84
+ v.push(r), r.classList.add("medium-zoom-image");
85
+ }), O.forEach(function(r) {
86
+ var f = r.type, p = r.listener, w = r.options;
87
+ l.forEach(function(y) {
88
+ y.addEventListener(f, p, w);
89
+ });
90
+ }), c;
91
+ }, _ = function() {
92
+ for (var o = arguments.length, n = Array(o), d = 0; d < o; d++)
93
+ n[d] = arguments[d];
94
+ e.zoomed && z();
95
+ var l = n.length > 0 ? n.reduce(function(r, f) {
96
+ return [].concat(r, W(f));
97
+ }, []) : v;
98
+ return l.forEach(function(r) {
99
+ r.classList.remove("medium-zoom-image"), r.dispatchEvent(L("medium-zoom:detach", {
100
+ detail: { zoom: c }
101
+ }));
102
+ }), v = v.filter(function(r) {
103
+ return l.indexOf(r) === -1;
104
+ }), c;
105
+ }, F = function(o, n) {
106
+ var d = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
107
+ return v.forEach(function(l) {
108
+ l.addEventListener("medium-zoom:" + o, n, d);
109
+ }), O.push({ type: "medium-zoom:" + o, listener: n, options: d }), c;
110
+ }, X = function(o, n) {
111
+ var d = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
112
+ return v.forEach(function(l) {
113
+ l.removeEventListener("medium-zoom:" + o, n, d);
114
+ }), O = O.filter(function(l) {
115
+ return !(l.type === "medium-zoom:" + o && l.listener.toString() === n.toString());
116
+ }), c;
117
+ }, Y = function() {
118
+ var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = o.target, d = function() {
119
+ var r = {
120
+ width: document.documentElement.clientWidth,
121
+ height: document.documentElement.clientHeight,
122
+ left: 0,
123
+ top: 0,
124
+ right: 0,
125
+ bottom: 0
126
+ }, f = void 0, p = void 0;
127
+ if (i.container)
128
+ if (i.container instanceof Object)
129
+ r = E({}, r, i.container), f = r.width - r.left - r.right - i.margin * 2, p = r.height - r.top - r.bottom - i.margin * 2;
130
+ else {
131
+ var w = A(i.container) ? i.container : document.querySelector(i.container), y = w.getBoundingClientRect(), k = y.width, J = y.height, Q = y.left, V = y.top;
132
+ r = E({}, r, {
133
+ width: k,
134
+ height: J,
135
+ left: Q,
136
+ top: V
137
+ });
138
+ }
139
+ f = f || r.width - i.margin * 2, p = p || r.height - i.margin * 2;
140
+ var H = e.zoomedHd || e.original, $ = U(H) ? f : H.naturalWidth || f, ee = U(H) ? p : H.naturalHeight || p, T = H.getBoundingClientRect(), te = T.top, oe = T.left, M = T.width, P = T.height, ne = Math.min(Math.max(M, $), f) / M, re = Math.min(Math.max(P, ee), p) / P, q = Math.min(ne, re), ie = (-oe + (f - M) / 2 + i.margin + r.left) / q, ae = (-te + (p - P) / 2 + i.margin + r.top) / q, R = "scale(" + q + ") translate3d(" + ie + "px, " + ae + "px, 0)";
141
+ e.zoomed.style.transform = R, e.zoomedHd && (e.zoomedHd.style.transform = R);
142
+ };
143
+ return new u(function(l) {
144
+ if (n && v.indexOf(n) === -1) {
145
+ l(c);
146
+ return;
147
+ }
148
+ var r = function k() {
149
+ b = !1, e.zoomed.removeEventListener("transitionend", k), e.original.dispatchEvent(L("medium-zoom:opened", {
150
+ detail: { zoom: c }
151
+ })), l(c);
152
+ };
153
+ if (e.zoomed) {
154
+ l(c);
155
+ return;
156
+ }
157
+ if (n)
158
+ e.original = n;
159
+ else if (v.length > 0) {
160
+ var f = v;
161
+ e.original = f[0];
162
+ } else {
163
+ l(c);
164
+ return;
165
+ }
166
+ if (e.original.dispatchEvent(L("medium-zoom:open", {
167
+ detail: { zoom: c }
168
+ })), B = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0, b = !0, e.zoomed = le(e.original), document.body.appendChild(S), i.template) {
169
+ var p = A(i.template) ? i.template : document.querySelector(i.template);
170
+ e.template = document.createElement("div"), e.template.appendChild(p.content.cloneNode(!0)), document.body.appendChild(e.template);
171
+ }
172
+ if (e.original.parentElement && e.original.parentElement.tagName === "PICTURE" && e.original.currentSrc && (e.zoomed.src = e.original.currentSrc), document.body.appendChild(e.zoomed), window.requestAnimationFrame(function() {
173
+ document.body.classList.add("medium-zoom--opened");
174
+ }), e.original.classList.add("medium-zoom-image--hidden"), e.zoomed.classList.add("medium-zoom-image--opened"), e.zoomed.addEventListener("click", z), e.zoomed.addEventListener("transitionend", r), e.original.getAttribute("data-zoom-src")) {
175
+ e.zoomedHd = e.zoomed.cloneNode(), e.zoomedHd.removeAttribute("srcset"), e.zoomedHd.removeAttribute("sizes"), e.zoomedHd.removeAttribute("loading"), e.zoomedHd.src = e.zoomed.getAttribute("data-zoom-src"), e.zoomedHd.onerror = function() {
176
+ clearInterval(w), console.warn("Unable to reach the zoom image target " + e.zoomedHd.src), e.zoomedHd = null, d();
177
+ };
178
+ var w = setInterval(function() {
179
+ e.zoomedHd.complete && (clearInterval(w), e.zoomedHd.classList.add("medium-zoom-image--opened"), e.zoomedHd.addEventListener("click", z), document.body.appendChild(e.zoomedHd), d());
180
+ }, 10);
181
+ } else if (e.original.hasAttribute("srcset")) {
182
+ e.zoomedHd = e.zoomed.cloneNode(), e.zoomedHd.removeAttribute("sizes"), e.zoomedHd.removeAttribute("loading");
183
+ var y = e.zoomedHd.addEventListener("load", function() {
184
+ e.zoomedHd.removeEventListener("load", y), e.zoomedHd.classList.add("medium-zoom-image--opened"), e.zoomedHd.addEventListener("click", z), document.body.appendChild(e.zoomedHd), d();
185
+ });
186
+ } else
187
+ d();
188
+ });
189
+ }, z = function() {
190
+ return new u(function(o) {
191
+ if (b || !e.original) {
192
+ o(c);
193
+ return;
194
+ }
195
+ var n = function d() {
196
+ e.original.classList.remove("medium-zoom-image--hidden"), document.body.removeChild(e.zoomed), e.zoomedHd && document.body.removeChild(e.zoomedHd), document.body.removeChild(S), e.zoomed.classList.remove("medium-zoom-image--opened"), e.template && document.body.removeChild(e.template), b = !1, e.zoomed.removeEventListener("transitionend", d), e.original.dispatchEvent(L("medium-zoom:closed", {
197
+ detail: { zoom: c }
198
+ })), e.original = null, e.zoomed = null, e.zoomedHd = null, e.template = null, o(c);
199
+ };
200
+ b = !0, document.body.classList.remove("medium-zoom--opened"), e.zoomed.style.transform = "", e.zoomedHd && (e.zoomedHd.style.transform = ""), e.template && (e.template.style.transition = "opacity 150ms", e.template.style.opacity = 0), e.original.dispatchEvent(L("medium-zoom:close", {
201
+ detail: { zoom: c }
202
+ })), e.zoomed.addEventListener("transitionend", n);
203
+ });
204
+ }, Z = function() {
205
+ var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = o.target;
206
+ return e.original ? z() : Y({ target: n });
207
+ }, K = function() {
208
+ return i;
209
+ }, D = function() {
210
+ return v;
211
+ }, G = function() {
212
+ return e.original;
213
+ }, v = [], O = [], b = !1, B = 0, i = a, e = {
214
+ original: null,
215
+ zoomed: null,
216
+ zoomedHd: null,
217
+ template: null
218
+ // If the selector is omitted, it's replaced by the options
219
+ };
220
+ Object.prototype.toString.call(t) === "[object Object]" ? i = t : (t || typeof t == "string") && C(t), i = E({
221
+ margin: 0,
222
+ background: "#fff",
223
+ scrollOffset: 40,
224
+ container: null,
225
+ template: null
226
+ }, i);
227
+ var S = me(i.background);
228
+ document.addEventListener("click", g), document.addEventListener("keyup", I), document.addEventListener("scroll", N), window.addEventListener("resize", z);
229
+ var c = {
230
+ open: Y,
231
+ close: z,
232
+ toggle: Z,
233
+ update: h,
234
+ clone: j,
235
+ attach: C,
236
+ detach: _,
237
+ on: F,
238
+ off: X,
239
+ getOptions: K,
240
+ getImages: D,
241
+ getZoomedImage: G
242
+ };
243
+ return c;
244
+ };
245
+ function ce(m, t) {
246
+ t === void 0 && (t = {});
247
+ var a = t.insertAt;
248
+ if (!(typeof document > "u")) {
249
+ var u = document.head || document.getElementsByTagName("head")[0], g = document.createElement("style");
250
+ g.type = "text/css", a === "top" && u.firstChild ? u.insertBefore(g, u.firstChild) : u.appendChild(g), g.styleSheet ? g.styleSheet.cssText = m : g.appendChild(document.createTextNode(m));
251
+ }
252
+ }
253
+ var se = ".medium-zoom-overlay{position:fixed;top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .3s;will-change:opacity}.medium-zoom--opened .medium-zoom-overlay{cursor:pointer;cursor:zoom-out;opacity:1}.medium-zoom-image{cursor:pointer;cursor:zoom-in;transition:transform .3s cubic-bezier(.2,0,.2,1)!important}.medium-zoom-image--hidden{visibility:hidden}.medium-zoom-image--opened{position:relative;cursor:pointer;cursor:zoom-out;will-change:transform}";
254
+ ce(se);
255
+ const fe = (m) => {
256
+ if (!m.selector)
257
+ return;
258
+ const t = ue(m.zoomOptions);
259
+ t.refresh = (a = m.selector) => {
260
+ t.detach(), t.attach(a);
261
+ }, setTimeout(() => t.refresh(m.selector), m.delay || 1e3);
262
+ };
263
+ export {
264
+ fe as useMediumZoom
265
+ };
@@ -2,5 +2,6 @@ import type { Theme } from 'vitepress';
2
2
  import './styles/index.css';
3
3
  export type * from './types';
4
4
  declare const theme: Theme;
5
- export type { DonationPluginConfig, GoogleAnalyticsOptions, Post, PostDate, Project, ThemeConfig, } from './types';
5
+ export * from './composables';
6
+ export type * from './types';
6
7
  export default theme;
@@ -1,5 +1,10 @@
1
1
  import "@iconify/vue";
2
- import { k as a } from "./index-CZCdwVUW.js";
2
+ import { k as t, l as u, m as l, p as o, q as r, x as S } from "./index-C43AnX3f.js";
3
3
  export {
4
- a as default
4
+ t as default,
5
+ u as usePostDate,
6
+ l as useProjectStatusStyle,
7
+ o as useRank,
8
+ r as useSlug,
9
+ S as useSlugFilter
5
10
  };
@@ -0,0 +1,14 @@
1
+ declare module 'medium-zoom' {
2
+ interface Zoom {
3
+ refresh: (selector?: string) => void;
4
+ }
5
+ }
6
+ export type MediumZoomPluginConfig = {
7
+ selector: string;
8
+ zoomOptions?: string;
9
+ delay?: number;
10
+ };
11
+ /**
12
+ * Inject medium zoom instance
13
+ */
14
+ export declare const useMediumZoom: (config: MediumZoomPluginConfig) => void;
@@ -0,0 +1,59 @@
1
+ export declare interface SharingPluginConfig {
2
+ networks?: string[];
3
+ displayMode?: string;
4
+ buttonSize?: number;
5
+ iconSize?: number;
6
+ iconStyle?: string;
7
+ }
8
+ export type SharingButtonComponentProps = {
9
+ /**
10
+ * URL to share
11
+ * @type string
12
+ */
13
+ url: string;
14
+ /**
15
+ * Share text
16
+ * @type string
17
+ */
18
+ text: string;
19
+ /**
20
+ * Social network
21
+ * @type string
22
+ */
23
+ network: string;
24
+ /**
25
+ * Button size
26
+ * @type number
27
+ */
28
+ buttonSize: number;
29
+ /**
30
+ * Icon style
31
+ * @type string
32
+ */
33
+ iconStyle: string;
34
+ /**
35
+ * Icon size
36
+ * @type number
37
+ * @default 32
38
+ */
39
+ iconSize?: number;
40
+ /**
41
+ * Display mode
42
+ * @type string
43
+ * @default icon
44
+ */
45
+ displayMode?: string;
46
+ };
47
+ export type SharingComponentProps = {
48
+ /**
49
+ * URL to share
50
+ * @type string
51
+ */
52
+ url: string;
53
+ /**
54
+ * Share text
55
+ * @type string
56
+ */
57
+ text: string;
58
+ };
59
+ export declare const useUrlQueryParamsBuilder: (params: Record<string, string | undefined> | undefined) => string;
@@ -0,0 +1,10 @@
1
+ import type * as Swetrix from 'swetrix';
2
+ export interface SwetrixOptions {
3
+ /**
4
+ * The Swetrix ID.
5
+ *
6
+ * @default process.env.VITE_SWETRIX_ID
7
+ */
8
+ id: string;
9
+ options?: Swetrix.LibOptions;
10
+ }