dumi-theme-lobehub 1.8.4 → 1.8.6
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/dist/builtins/Container/index.js +9 -15
- package/dist/builtins/Previewer/index.js +9 -3
- package/dist/components/Analytics/Clarity.d.ts +5 -0
- package/dist/components/Analytics/Clarity.js +12 -0
- package/dist/components/Analytics/GoogleAnalytics.d.ts +5 -0
- package/dist/components/Analytics/GoogleAnalytics.js +20 -0
- package/dist/components/Analytics/Plausible.d.ts +6 -0
- package/dist/components/Analytics/Plausible.js +12 -0
- package/dist/components/Analytics/index.d.ts +2 -0
- package/dist/components/Analytics/index.js +21 -0
- package/dist/components/StoreUpdater/index.js +4 -0
- package/dist/layouts/DemoLayout/GlobalStyle.d.ts +3 -0
- package/dist/layouts/DemoLayout/GlobalStyle.js +8 -0
- package/dist/layouts/DemoLayout/index.js +39 -9
- package/dist/layouts/DocLayout/DocumentLayout.js +4 -4
- package/dist/layouts/DocLayout/GlobalStyle.js +1 -1
- package/dist/layouts/DocLayout/Head/Favicons.js +56 -0
- package/dist/layouts/DocLayout/Head/Og.d.ts +3 -0
- package/dist/layouts/DocLayout/Head/Og.js +74 -0
- package/dist/layouts/DocLayout/index.js +4 -2
- package/dist/pages/Changelog/index.js +3 -8
- package/dist/pages/Docs/index.js +3 -3
- package/dist/slots/ApiHeader/index.js +2 -2
- package/dist/slots/Content/index.js +2 -2
- package/dist/slots/Content/style.js +1 -1
- package/dist/slots/ContentFooter/index.js +2 -2
- package/dist/slots/Features/index.js +2 -2
- package/dist/slots/Footer/index.js +2 -2
- package/dist/slots/Header/Burger.js +2 -2
- package/dist/slots/Header/DiscordButton.js +2 -2
- package/dist/slots/Header/GithubButton.js +77 -4
- package/dist/slots/Header/index.js +1 -1
- package/dist/slots/Hero/index.js +14 -4
- package/dist/slots/Logo/index.js +2 -2
- package/dist/slots/Navbar/index.js +2 -2
- package/dist/slots/Toc/index.js +2 -2
- package/dist/store/index.d.ts +0 -15
- package/dist/store/index.js +1 -18
- package/dist/store/initialState.d.ts +1 -0
- package/dist/store/initialState.js +20 -3
- package/dist/store/selectors/apiHeader.d.ts +4 -3
- package/dist/store/selectors/apiHeader.js +8 -5
- package/dist/store/selectors/hero.d.ts +7 -22
- package/dist/store/selectors/hero.js +29 -28
- package/dist/store/selectors/index.d.ts +3 -23
- package/dist/store/selectors/index.js +3 -71
- package/dist/store/selectors/site.d.ts +60 -0
- package/dist/store/selectors/site.js +111 -0
- package/dist/store/useSiteStore.d.ts +2 -5
- package/dist/types/config.d.ts +36 -2
- package/package.json +1 -1
- package/dist/builtins/Container/style.d.ts +0 -5
- package/dist/builtins/Container/style.js +0 -27
- package/dist/components/Favicons/index.js +0 -43
- package/dist/store/selectors/siteBasicInfo.d.ts +0 -11
- package/dist/store/selectors/siteBasicInfo.js +0 -27
- package/dist/store/selectors/token.d.ts +0 -2
- package/dist/store/selectors/token.js +0 -5
- /package/dist/{components/Favicons/index.d.ts → layouts/DocLayout/Head/Favicons.d.ts} +0 -0
|
@@ -4,7 +4,7 @@ import { ActionIcon } from '@lobehub/ui';
|
|
|
4
4
|
import { createStyles } from 'antd-style';
|
|
5
5
|
import { createLucideIcon } from 'lucide-react';
|
|
6
6
|
import { memo } from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { siteSelectors, useSiteStore } from "../../store";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
var Discord = createLucideIcon('Discord', [['path', {
|
|
10
10
|
d: 'M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z',
|
|
@@ -15,7 +15,7 @@ var useStyles = createStyles(function (_ref) {
|
|
|
15
15
|
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n svg {\n overflow: visible !important;\n }\n "])));
|
|
16
16
|
});
|
|
17
17
|
var DiscordButton = /*#__PURE__*/memo(function () {
|
|
18
|
-
var inviteUrl = useSiteStore(
|
|
18
|
+
var inviteUrl = useSiteStore(siteSelectors.discord);
|
|
19
19
|
var _useStyles = useStyles(),
|
|
20
20
|
styles = _useStyles.styles;
|
|
21
21
|
return inviteUrl ? /*#__PURE__*/_jsx("a", {
|
|
@@ -1,11 +1,68 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _templateObject;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
1
7
|
import { ActionIcon } from '@lobehub/ui';
|
|
8
|
+
import { createStyles } from 'antd-style';
|
|
2
9
|
import { Github } from 'lucide-react';
|
|
10
|
+
import { rgba } from 'polished';
|
|
3
11
|
import { memo } from 'react';
|
|
4
|
-
import
|
|
12
|
+
import useSWR from 'swr';
|
|
13
|
+
import { siteSelectors, useSiteStore } from "../../store";
|
|
5
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
var useStyles = createStyles(function (_ref) {
|
|
16
|
+
var css = _ref.css,
|
|
17
|
+
token = _ref.token;
|
|
18
|
+
return {
|
|
19
|
+
button: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n\n font-weight: bold;\n color: ", ";\n\n border: 1px solid ", ";\n border-radius: 36px !important;\n\n transition: all 0.2s ease-in-out;\n\n &::before {\n content: '';\n\n position: absolute;\n inset-block-end: 0;\n\n display: block;\n\n width: 50%;\n height: 1px;\n\n opacity: 0;\n background-image: linear-gradient(to right, transparent, ", ", transparent);\n\n transition: all 0.2s ease-in-out;\n }\n\n &:hover {\n background: ", ";\n\n &::before {\n opacity: 1;\n }\n }\n "])), token.colorTextSecondary, rgba(token.colorText, 0.1), token.gold, token.colorBgContainer)
|
|
20
|
+
};
|
|
21
|
+
});
|
|
6
22
|
var GithubButton = /*#__PURE__*/memo(function () {
|
|
7
|
-
var
|
|
8
|
-
|
|
23
|
+
var _useStyles = useStyles(),
|
|
24
|
+
styles = _useStyles.styles;
|
|
25
|
+
var repoUrl = useSiteStore(siteSelectors.github);
|
|
26
|
+
var _useSWR = useSWR('github-star', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
27
|
+
var url, res, json;
|
|
28
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
29
|
+
while (1) switch (_context.prev = _context.next) {
|
|
30
|
+
case 0:
|
|
31
|
+
if (repoUrl) {
|
|
32
|
+
_context.next = 2;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return _context.abrupt("return", 0);
|
|
36
|
+
case 2:
|
|
37
|
+
url = repoUrl.replace('https://github.com/', 'https://api.github.com/repos/');
|
|
38
|
+
_context.next = 5;
|
|
39
|
+
return fetch(url);
|
|
40
|
+
case 5:
|
|
41
|
+
res = _context.sent;
|
|
42
|
+
if (res.ok) {
|
|
43
|
+
_context.next = 8;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return _context.abrupt("return", 0);
|
|
47
|
+
case 8:
|
|
48
|
+
_context.next = 10;
|
|
49
|
+
return res.json();
|
|
50
|
+
case 10:
|
|
51
|
+
json = _context.sent;
|
|
52
|
+
return _context.abrupt("return", json.stargazers_count);
|
|
53
|
+
case 12:
|
|
54
|
+
case "end":
|
|
55
|
+
return _context.stop();
|
|
56
|
+
}
|
|
57
|
+
}, _callee);
|
|
58
|
+
})), {
|
|
59
|
+
refreshWhenOffline: false,
|
|
60
|
+
revalidateOnFocus: false,
|
|
61
|
+
revalidateOnReconnect: false
|
|
62
|
+
}),
|
|
63
|
+
githubStar = _useSWR.data;
|
|
64
|
+
if (!repoUrl) return;
|
|
65
|
+
if (!githubStar) return /*#__PURE__*/_jsx("a", {
|
|
9
66
|
href: repoUrl,
|
|
10
67
|
rel: "noreferrer",
|
|
11
68
|
target: '_blank',
|
|
@@ -13,6 +70,22 @@ var GithubButton = /*#__PURE__*/memo(function () {
|
|
|
13
70
|
icon: Github,
|
|
14
71
|
size: "site"
|
|
15
72
|
})
|
|
16
|
-
})
|
|
73
|
+
});
|
|
74
|
+
return /*#__PURE__*/_jsx("a", {
|
|
75
|
+
href: repoUrl,
|
|
76
|
+
rel: "noreferrer",
|
|
77
|
+
target: '_blank',
|
|
78
|
+
children: /*#__PURE__*/_jsx(ActionIcon, {
|
|
79
|
+
className: styles.button,
|
|
80
|
+
gap: 4,
|
|
81
|
+
icon: Github,
|
|
82
|
+
paddingInline: 16,
|
|
83
|
+
size: "site",
|
|
84
|
+
style: {
|
|
85
|
+
width: 'unset'
|
|
86
|
+
},
|
|
87
|
+
children: githubStar > 1000 ? (githubStar / 1000).toFixed(1) + 'K' : githubStar + ' ⭐️'
|
|
88
|
+
})
|
|
89
|
+
});
|
|
17
90
|
});
|
|
18
91
|
export default GithubButton;
|
|
@@ -22,7 +22,7 @@ var Header = /*#__PURE__*/memo(function () {
|
|
|
22
22
|
if (!hasHeader) return;
|
|
23
23
|
return /*#__PURE__*/_jsx(Head, {
|
|
24
24
|
actions: mobile ? /*#__PURE__*/_jsx(ThemeSwitch, {}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
25
|
-
children: [/*#__PURE__*/_jsx(SearchBar, {}),
|
|
25
|
+
children: [/*#__PURE__*/_jsx(SearchBar, {}), /*#__PURE__*/_jsx(DiscordButton, {}), /*#__PURE__*/_jsx(LangSwitch, {}), /*#__PURE__*/_jsx(ThemeSwitch, {}), /*#__PURE__*/_jsx(GithubButton, {})]
|
|
26
26
|
}),
|
|
27
27
|
logo: /*#__PURE__*/_jsx(Logo, {}),
|
|
28
28
|
nav: mobile ? /*#__PURE__*/_jsx(Burger, {}) : /*#__PURE__*/_jsx(Navbar, {})
|
package/dist/slots/Hero/index.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1
7
|
import { Hero as H } from '@lobehub/ui';
|
|
2
8
|
import { memo } from 'react';
|
|
3
|
-
import {
|
|
9
|
+
import { heroSelectors, useSiteStore } from "../../store";
|
|
4
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
11
|
var Hero = /*#__PURE__*/memo(function () {
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
var _useSiteStore = useSiteStore(function (s) {
|
|
13
|
+
return [heroSelectors.heroTitle(s), heroSelectors.heroDesc(s), heroSelectors.heroActions(s)];
|
|
14
|
+
}),
|
|
15
|
+
_useSiteStore2 = _slicedToArray(_useSiteStore, 3),
|
|
16
|
+
title = _useSiteStore2[0],
|
|
17
|
+
description = _useSiteStore2[1],
|
|
18
|
+
actions = _useSiteStore2[2];
|
|
9
19
|
return /*#__PURE__*/_jsx(H, {
|
|
10
20
|
actions: actions,
|
|
11
21
|
description: description,
|
package/dist/slots/Logo/index.js
CHANGED
|
@@ -4,13 +4,13 @@ import { useResponsive } from 'antd-style';
|
|
|
4
4
|
import { Link } from 'dumi';
|
|
5
5
|
import isEqual from 'fast-deep-equal';
|
|
6
6
|
import { memo } from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { siteSelectors } from "../../store";
|
|
8
8
|
import { useSiteStore } from "../../store/useSiteStore";
|
|
9
9
|
import { useStyles } from "./style";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
var Logo = /*#__PURE__*/memo(function () {
|
|
13
|
-
var config = useSiteStore(themeConfig, isEqual);
|
|
13
|
+
var config = useSiteStore(siteSelectors.themeConfig, isEqual);
|
|
14
14
|
var locale = useSiteStore(function (s) {
|
|
15
15
|
return s.locale;
|
|
16
16
|
}, isEqual);
|
|
@@ -5,7 +5,7 @@ import { createStyles } from 'antd-style';
|
|
|
5
5
|
import { Link, history } from 'dumi';
|
|
6
6
|
import NavbarExtra from 'dumi/theme-default/slots/NavbarExtra';
|
|
7
7
|
import { memo } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { siteSelectors, useSiteStore } from "../../store";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -27,7 +27,7 @@ var Navbar = /*#__PURE__*/memo(function () {
|
|
|
27
27
|
var nav = useSiteStore(function (s) {
|
|
28
28
|
return s.navData;
|
|
29
29
|
});
|
|
30
|
-
var activePath = useSiteStore(
|
|
30
|
+
var activePath = useSiteStore(siteSelectors.activePath);
|
|
31
31
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
32
32
|
children: [/*#__PURE__*/_jsx(TabsNav, {
|
|
33
33
|
activeKey: activePath,
|
package/dist/slots/Toc/index.js
CHANGED
|
@@ -8,13 +8,13 @@ import { Toc as T } from '@lobehub/ui';
|
|
|
8
8
|
import { useResponsive, useTheme } from 'antd-style';
|
|
9
9
|
import isEqual from 'fast-deep-equal';
|
|
10
10
|
import { memo, useEffect, useState } from 'react';
|
|
11
|
-
import {
|
|
11
|
+
import { siteSelectors, useSiteStore } from "../../store";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
var GAP = 48;
|
|
16
16
|
var Toc = /*#__PURE__*/memo(function () {
|
|
17
|
-
var items = useSiteStore(
|
|
17
|
+
var items = useSiteStore(siteSelectors.tocAnchorItem, isEqual);
|
|
18
18
|
var _useResponsive = useResponsive(),
|
|
19
19
|
mobile = _useResponsive.mobile;
|
|
20
20
|
var theme = useTheme();
|
package/dist/store/index.d.ts
CHANGED
|
@@ -2,18 +2,3 @@ export { initialState } from './initialState';
|
|
|
2
2
|
export * from './selectors';
|
|
3
3
|
export * from './useSiteStore';
|
|
4
4
|
export * from './useThemeStore';
|
|
5
|
-
/**
|
|
6
|
-
* @title 数据选择器
|
|
7
|
-
*/
|
|
8
|
-
export declare const siteSelectors: {
|
|
9
|
-
/**
|
|
10
|
-
* @title API 头部选择器
|
|
11
|
-
*/
|
|
12
|
-
apiHeader: (s: import("./useSiteStore").SiteStore) => import("../components/ApiHeader").ApiHeaderProps;
|
|
13
|
-
/**
|
|
14
|
-
* @title 扁平化侧边栏选择器
|
|
15
|
-
*/
|
|
16
|
-
flattenSidebar: (s: import("./useSiteStore").SiteStore) => import("dumi/dist/client/theme-api/types").ISidebarItem[];
|
|
17
|
-
logo: (s: import("./useSiteStore").SiteStore) => string;
|
|
18
|
-
token: (s: import("./useSiteStore").SiteStore) => any;
|
|
19
|
-
};
|
package/dist/store/index.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import { apiHeaderSel, flattenSidebarSel, logoSel, tokenSel } from "./selectors";
|
|
2
1
|
export { initialState } from "./initialState";
|
|
3
2
|
export * from "./selectors";
|
|
4
3
|
export * from "./useSiteStore";
|
|
5
|
-
export * from "./useThemeStore";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @title 数据选择器
|
|
9
|
-
*/
|
|
10
|
-
export var siteSelectors = {
|
|
11
|
-
/**
|
|
12
|
-
* @title API 头部选择器
|
|
13
|
-
*/
|
|
14
|
-
apiHeader: apiHeaderSel,
|
|
15
|
-
/**
|
|
16
|
-
* @title 扁平化侧边栏选择器
|
|
17
|
-
*/
|
|
18
|
-
flattenSidebar: flattenSidebarSel,
|
|
19
|
-
logo: logoSel,
|
|
20
|
-
token: tokenSel
|
|
21
|
-
};
|
|
4
|
+
export * from "./useThemeStore";
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
export var initialThemeConfig = {
|
|
2
|
+
footer: 'Made with 🤯 by <a href="https://lobehub.com" target="_blank">LobeHub</a>',
|
|
3
|
+
metadata: {
|
|
4
|
+
icons: {
|
|
5
|
+
apple: 'https://lobehub.com/apple-touch-icon.png',
|
|
6
|
+
icon: 'https://lobehub.com/favicon-32x32.png',
|
|
7
|
+
shortcut: 'https://lobehub.com/favicon.ico'
|
|
8
|
+
},
|
|
9
|
+
manifest: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/site.webmanifest',
|
|
10
|
+
openGraph: {
|
|
11
|
+
siteName: 'LobeHub'
|
|
12
|
+
},
|
|
13
|
+
twitter: {
|
|
14
|
+
site: '@lobehub'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
1
18
|
export var initialState = {
|
|
2
19
|
locale: {
|
|
3
|
-
id: '
|
|
4
|
-
name: '
|
|
20
|
+
id: 'en-US',
|
|
21
|
+
name: 'English',
|
|
5
22
|
suffix: ''
|
|
6
23
|
},
|
|
7
24
|
location: {
|
|
@@ -30,6 +47,6 @@ export var initialState = {
|
|
|
30
47
|
// @ts-ignore
|
|
31
48
|
setLoading: undefined,
|
|
32
49
|
// @ts-ignore
|
|
33
|
-
themeConfig:
|
|
50
|
+
themeConfig: initialThemeConfig
|
|
34
51
|
}
|
|
35
52
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ApiHeaderProps } from '../../components/ApiHeader';
|
|
2
2
|
import type { SiteStore } from '../useSiteStore';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare const apiHeaderSelectors: {
|
|
4
|
+
apiHeader: (s: SiteStore) => ApiHeaderProps;
|
|
5
|
+
isApiPage: (s: SiteStore) => boolean;
|
|
6
|
+
};
|
|
@@ -4,13 +4,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
6
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
-
import {
|
|
8
|
-
export * from "./hero";
|
|
7
|
+
import { siteSelectors } from "./site";
|
|
9
8
|
var haseUrl = function haseUrl(config) {
|
|
10
9
|
if (config === false) return false;
|
|
11
10
|
return typeof config === 'string';
|
|
12
11
|
};
|
|
13
|
-
|
|
12
|
+
var isApiPage = function isApiPage(s) {
|
|
14
13
|
var _s$siteData$themeConf;
|
|
15
14
|
var fm = s.routeMeta.frontmatter;
|
|
16
15
|
if (s.siteData.themeConfig.apiHeader === false || fm.apiHeader === false) return false;
|
|
@@ -20,9 +19,9 @@ export var isApiPageSel = function isApiPageSel(s) {
|
|
|
20
19
|
return s.location.pathname.startsWith(path);
|
|
21
20
|
});
|
|
22
21
|
};
|
|
23
|
-
|
|
22
|
+
var apiHeader = function apiHeader(s) {
|
|
24
23
|
var _fm$apiHeader, _fm$apiHeader2, _fm$apiHeader3, _fm$apiHeader4;
|
|
25
|
-
var REPO_BASE =
|
|
24
|
+
var REPO_BASE = siteSelectors.github(s);
|
|
26
25
|
var fm = s.routeMeta.frontmatter;
|
|
27
26
|
var localeId = s.locale.id;
|
|
28
27
|
var replaceUrl = function replaceUrl(rawString) {
|
|
@@ -50,4 +49,8 @@ export var apiHeaderSel = function apiHeaderSel(s) {
|
|
|
50
49
|
title: fm.title,
|
|
51
50
|
type: type
|
|
52
51
|
};
|
|
52
|
+
};
|
|
53
|
+
export var apiHeaderSelectors = {
|
|
54
|
+
apiHeader: apiHeader,
|
|
55
|
+
isApiPage: isApiPage
|
|
53
56
|
};
|
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
import { type FeatureItem } from '@lobehub/ui';
|
|
2
2
|
import { SiteStore } from '../useSiteStore';
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const heroTitleSel: (s: SiteStore) => any;
|
|
11
|
-
/**
|
|
12
|
-
* Hero description 选择器
|
|
13
|
-
* 选择逻辑:优先使用 hero 配置的 description, 再兜底到 themeConfig 中的 name
|
|
14
|
-
*/
|
|
15
|
-
export declare const heroDescSel: (s: SiteStore) => any;
|
|
16
|
-
/**
|
|
17
|
-
* Hero Action 选择器
|
|
18
|
-
* 选择逻辑:优先使用 hero 配置的 actions, 再兜底到 themeConfig 中的 actions
|
|
19
|
-
*/
|
|
20
|
-
export declare const heroActionsSel: (s: SiteStore) => any;
|
|
21
|
-
/**
|
|
22
|
-
* Features 选择器
|
|
23
|
-
*/
|
|
24
|
-
export declare const featuresSel: (s: SiteStore) => FeatureItem[];
|
|
3
|
+
export declare const heroSelectors: {
|
|
4
|
+
features: (s: SiteStore) => FeatureItem[];
|
|
5
|
+
heroActions: (s: SiteStore) => any;
|
|
6
|
+
heroDesc: (s: SiteStore) => any;
|
|
7
|
+
heroTitle: (s: SiteStore) => any;
|
|
8
|
+
isHeroPage: (s: SiteStore) => boolean;
|
|
9
|
+
};
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
var isHeroPage = function isHeroPage(s) {
|
|
2
2
|
return s.location.pathname === '/';
|
|
3
3
|
};
|
|
4
|
-
|
|
5
|
-
// 是否展示首页的自定义内容
|
|
6
|
-
export var showHeroPageCustomContent = function showHeroPageCustomContent(s) {
|
|
7
|
-
var _s$routeMeta$frontmat, _s$siteData$themeConf;
|
|
8
|
-
return !!((_s$routeMeta$frontmat = s.routeMeta.frontmatter.hero) !== null && _s$routeMeta$frontmat !== void 0 && _s$routeMeta$frontmat.showCustomContent) || !!((_s$siteData$themeConf = s.siteData.themeConfig.hero) !== null && _s$siteData$themeConf !== void 0 && _s$siteData$themeConf.showCustomContent);
|
|
9
|
-
};
|
|
10
|
-
export var localeValueSel = function localeValueSel(s, value) {
|
|
4
|
+
var localeValue = function localeValue(s, value) {
|
|
11
5
|
if (!value) return;
|
|
12
6
|
if (value[s.locale.id]) return value[s.locale.id];
|
|
13
7
|
return value;
|
|
@@ -17,49 +11,56 @@ export var localeValueSel = function localeValueSel(s, value) {
|
|
|
17
11
|
* Hero Title 选择器
|
|
18
12
|
* 选择逻辑:优先使用 hero 配置的 title, 再兜底到 themeConfig 中的 name
|
|
19
13
|
*/
|
|
20
|
-
|
|
21
|
-
var _s$routeMeta$
|
|
22
|
-
return ((_s$routeMeta$
|
|
23
|
-
(
|
|
14
|
+
var heroTitle = function heroTitle(s) {
|
|
15
|
+
var _s$routeMeta$frontmat, _localeValue;
|
|
16
|
+
return ((_s$routeMeta$frontmat = s.routeMeta.frontmatter.hero) === null || _s$routeMeta$frontmat === void 0 ? void 0 : _s$routeMeta$frontmat.title) || ( // 从 hero 的 title 中选择
|
|
17
|
+
(_localeValue = localeValue(s, s.siteData.themeConfig.hero)) === null || _localeValue === void 0 ? void 0 : _localeValue.title) ||
|
|
24
18
|
// @deprecated 1.0 正式版本移除
|
|
25
19
|
// 从 hero 的 title 中选择
|
|
26
|
-
|
|
20
|
+
localeValue(s, s.siteData.themeConfig.title) || s.siteData.themeConfig.name;
|
|
27
21
|
};
|
|
28
22
|
|
|
29
23
|
/**
|
|
30
24
|
* Hero description 选择器
|
|
31
25
|
* 选择逻辑:优先使用 hero 配置的 description, 再兜底到 themeConfig 中的 name
|
|
32
26
|
*/
|
|
33
|
-
|
|
34
|
-
var _s$routeMeta$
|
|
35
|
-
return ((_s$routeMeta$
|
|
36
|
-
(
|
|
27
|
+
var heroDesc = function heroDesc(s) {
|
|
28
|
+
var _s$routeMeta$frontmat2, _localeValue2;
|
|
29
|
+
return ((_s$routeMeta$frontmat2 = s.routeMeta.frontmatter.hero) === null || _s$routeMeta$frontmat2 === void 0 ? void 0 : _s$routeMeta$frontmat2.description) || ( // 从 hero 的 description 中选择
|
|
30
|
+
(_localeValue2 = localeValue(s, s.siteData.themeConfig.hero)) === null || _localeValue2 === void 0 ? void 0 : _localeValue2.description) ||
|
|
37
31
|
// @deprecated 1.0 正式版本移除
|
|
38
32
|
// 从 hero 的 description 中选择
|
|
39
|
-
|
|
33
|
+
localeValue(s, s.siteData.themeConfig.description);
|
|
40
34
|
};
|
|
41
35
|
|
|
42
36
|
/**
|
|
43
37
|
* Hero Action 选择器
|
|
44
38
|
* 选择逻辑:优先使用 hero 配置的 actions, 再兜底到 themeConfig 中的 actions
|
|
45
39
|
*/
|
|
46
|
-
|
|
47
|
-
var _s$routeMeta$
|
|
48
|
-
return ((_s$routeMeta$
|
|
49
|
-
(
|
|
40
|
+
var heroActions = function heroActions(s) {
|
|
41
|
+
var _s$routeMeta$frontmat3, _localeValue3;
|
|
42
|
+
return ((_s$routeMeta$frontmat3 = s.routeMeta.frontmatter.hero) === null || _s$routeMeta$frontmat3 === void 0 ? void 0 : _s$routeMeta$frontmat3.actions) || ( // 从 hero 的 actions 中选择
|
|
43
|
+
(_localeValue3 = localeValue(s, s.siteData.themeConfig.hero)) === null || _localeValue3 === void 0 ? void 0 : _localeValue3.actions) ||
|
|
50
44
|
// @deprecated 1.0 正式版本移除
|
|
51
|
-
|
|
45
|
+
localeValue(s, s.siteData.themeConfig.actions);
|
|
52
46
|
};
|
|
53
47
|
|
|
54
48
|
/**
|
|
55
49
|
* Features 选择器
|
|
56
50
|
*/
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
if (!
|
|
60
|
-
return ((
|
|
51
|
+
var features = function features(s) {
|
|
52
|
+
var _localeValue4;
|
|
53
|
+
if (!isHeroPage(s)) return [];
|
|
54
|
+
return ((_localeValue4 = localeValue(s, s.siteData.themeConfig.hero)) === null || _localeValue4 === void 0 ? void 0 : _localeValue4.features) ||
|
|
61
55
|
// @deprecated 1.0 正式版本移除
|
|
62
|
-
|
|
56
|
+
localeValue(s, s.siteData.themeConfig.features) ||
|
|
63
57
|
// 在themeConfig 没有配置的话,尝试兜底到 frontmatter 中的配置
|
|
64
58
|
s.routeMeta.frontmatter.features || [];
|
|
59
|
+
};
|
|
60
|
+
export var heroSelectors = {
|
|
61
|
+
features: features,
|
|
62
|
+
heroActions: heroActions,
|
|
63
|
+
heroDesc: heroDesc,
|
|
64
|
+
heroTitle: heroTitle,
|
|
65
|
+
isHeroPage: isHeroPage
|
|
65
66
|
};
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export * from './apiHeader';
|
|
5
|
-
export * from './hero';
|
|
6
|
-
export * from './siteBasicInfo';
|
|
7
|
-
export * from './token';
|
|
8
|
-
export declare const activePathSel: (s: SiteStore) => string;
|
|
9
|
-
/**
|
|
10
|
-
* toc 锚点选择器
|
|
11
|
-
* @param s
|
|
12
|
-
*/
|
|
13
|
-
export declare const tocAnchorItemSel: (s: SiteStore) => AnchorItem[];
|
|
14
|
-
/**
|
|
15
|
-
* 将 sidebar 信息扁平化
|
|
16
|
-
* @param s
|
|
17
|
-
*/
|
|
18
|
-
export declare const flattenSidebarSel: (s: SiteStore) => ISidebarItem[];
|
|
19
|
-
export declare const contentBottomSel: (s: SiteStore) => {
|
|
20
|
-
currentIndex: number;
|
|
21
|
-
next: ISidebarItem;
|
|
22
|
-
prev: ISidebarItem;
|
|
23
|
-
};
|
|
1
|
+
export { apiHeaderSelectors } from './apiHeader';
|
|
2
|
+
export { heroSelectors } from './hero';
|
|
3
|
+
export { siteSelectors } from './site';
|
|
@@ -1,71 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
export * from "./apiHeader";
|
|
8
|
-
export * from "./hero";
|
|
9
|
-
export * from "./siteBasicInfo";
|
|
10
|
-
export * from "./token";
|
|
11
|
-
export var activePathSel = function activePathSel(s) {
|
|
12
|
-
if (s.location.pathname === '/') return '/';
|
|
13
|
-
var item = s.navData.filter(function (index) {
|
|
14
|
-
return index.link !== '/';
|
|
15
|
-
}).find(function (index) {
|
|
16
|
-
return s.location.pathname.startsWith(String(index.activePath || index.link));
|
|
17
|
-
});
|
|
18
|
-
return (item === null || item === void 0 ? void 0 : item.activePath) || (item === null || item === void 0 ? void 0 : item.link) || '';
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* toc 锚点选择器
|
|
23
|
-
* @param s
|
|
24
|
-
*/
|
|
25
|
-
export var tocAnchorItemSel = function tocAnchorItemSel(s) {
|
|
26
|
-
var _s$tabMeta, _s$tabMeta2;
|
|
27
|
-
var _s$routeMeta = s.routeMeta,
|
|
28
|
-
toc = _s$routeMeta.toc,
|
|
29
|
-
frontmatter = _s$routeMeta.frontmatter;
|
|
30
|
-
if ((_s$tabMeta = s.tabMeta) !== null && _s$tabMeta !== void 0 && _s$tabMeta.toc) toc = s.tabMeta.toc;
|
|
31
|
-
if ((_s$tabMeta2 = s.tabMeta) !== null && _s$tabMeta2 !== void 0 && _s$tabMeta2.frontmatter) frontmatter = s.tabMeta.frontmatter;
|
|
32
|
-
var shouldKeepWith = function shouldKeepWith(depth) {
|
|
33
|
-
if (!frontmatter.tocDepth) return true;
|
|
34
|
-
if (typeof frontmatter.tocDepth === 'number' && frontmatter.tocDepth > depth - 1) return true;
|
|
35
|
-
};
|
|
36
|
-
return toc.reduce(function (result, item) {
|
|
37
|
-
if (item.depth === 2 && shouldKeepWith(2)) {
|
|
38
|
-
result.push(_objectSpread({}, item));
|
|
39
|
-
} else if (item.depth === 3 && shouldKeepWith(3)) {
|
|
40
|
-
var parent = result.at(-1);
|
|
41
|
-
if (parent) {
|
|
42
|
-
parent.children = parent.children || [];
|
|
43
|
-
parent.children.push(_objectSpread({}, item));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}, []);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 将 sidebar 信息扁平化
|
|
52
|
-
* @param s
|
|
53
|
-
*/
|
|
54
|
-
export var flattenSidebarSel = function flattenSidebarSel(s) {
|
|
55
|
-
var _s$sidebar;
|
|
56
|
-
return ((_s$sidebar = s.sidebar) === null || _s$sidebar === void 0 ? void 0 : _s$sidebar.map(function (index) {
|
|
57
|
-
return index.children;
|
|
58
|
-
}).flat()) || [];
|
|
59
|
-
};
|
|
60
|
-
export var contentBottomSel = function contentBottomSel(s) {
|
|
61
|
-
var dataFlatten = flattenSidebarSel(s);
|
|
62
|
-
var path = s.location.pathname;
|
|
63
|
-
var currentIndex = dataFlatten.findIndex(function (item) {
|
|
64
|
-
return item.link === path;
|
|
65
|
-
});
|
|
66
|
-
return {
|
|
67
|
-
currentIndex: currentIndex,
|
|
68
|
-
next: dataFlatten[currentIndex + 1],
|
|
69
|
-
prev: dataFlatten[currentIndex - 1]
|
|
70
|
-
};
|
|
71
|
-
};
|
|
1
|
+
export { apiHeaderSelectors } from "./apiHeader";
|
|
2
|
+
export { heroSelectors } from "./hero";
|
|
3
|
+
export { siteSelectors } from "./site";
|