dumi-theme-lobehub 1.9.1 → 1.10.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.
@@ -1,13 +1,13 @@
1
+ import { Helmet } from 'dumi';
1
2
  import { siteSelectors, useSiteStore } from "../../store";
2
3
  import ClarityAnalytics from "./Clarity";
3
4
  import GoogleAnalytics from "./GoogleAnalytics";
4
5
  import Plausible from "./Plausible";
5
6
  import { jsx as _jsx } from "react/jsx-runtime";
6
- import { Fragment as _Fragment } from "react/jsx-runtime";
7
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
8
  var Analytics = function Analytics() {
9
9
  var analytics = useSiteStore(siteSelectors.analytics);
10
- return /*#__PURE__*/_jsxs(_Fragment, {
10
+ return /*#__PURE__*/_jsxs(Helmet, {
11
11
  children: [(analytics === null || analytics === void 0 ? void 0 : analytics.googleAnalytics) && /*#__PURE__*/_jsx(GoogleAnalytics, {
12
12
  measurementId: analytics.googleAnalytics.measurementId
13
13
  }), (analytics === null || analytics === void 0 ? void 0 : analytics.clarity) && /*#__PURE__*/_jsx(ClarityAnalytics, {
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ declare const StructuredData: FC<{
3
+ ld: any;
4
+ }>;
5
+ export default StructuredData;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ var StructuredData = function StructuredData(_ref) {
3
+ var ld = _ref.ld;
4
+ return /*#__PURE__*/_jsx("script", {
5
+ dangerouslySetInnerHTML: {
6
+ __html: JSON.stringify(ld)
7
+ },
8
+ id: "structured-data",
9
+ type: "application/ld+json"
10
+ });
11
+ };
12
+ export default StructuredData;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare const Favicons: import("react").MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
1
+ import { FC } from 'react';
2
+ declare const Favicons: FC;
3
3
  export default Favicons;
@@ -6,11 +6,10 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { Helmet } from 'dumi';
8
8
  import isEqual from 'fast-deep-equal';
9
- import { memo } from 'react';
10
9
  import { siteSelectors, useSiteStore } from "../../../store";
11
10
  import { jsx as _jsx } from "react/jsx-runtime";
12
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
- var Favicons = /*#__PURE__*/memo(function () {
12
+ var Favicons = function Favicons() {
14
13
  var _metadata$icons, _metadata$icons2, _metadata$icons3;
15
14
  var _useSiteStore = useSiteStore(function (s) {
16
15
  return [siteSelectors.siteTitle(s), siteSelectors.logo(s)];
@@ -52,5 +51,5 @@ var Favicons = /*#__PURE__*/memo(function () {
52
51
  name: "theme-color"
53
52
  })]
54
53
  });
55
- });
54
+ };
56
55
  export default Favicons;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare const Og: import("react").MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
1
+ import { FC } from 'react';
2
+ declare const Og: FC;
3
3
  export default Og;
@@ -6,11 +6,11 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { Helmet } from 'dumi';
8
8
  import isEqual from 'fast-deep-equal';
9
- import { memo } from 'react';
9
+ import urlJoin from 'url-join';
10
10
  import { siteSelectors, useSiteStore } from "../../../store";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
- var Og = /*#__PURE__*/memo(function () {
13
+ var Og = function Og() {
14
14
  var _metadata$openGraph, _metadata$openGraph2, _metadata$openGraph3, _metadata$openGraph4, _metadata$openGraph5, _metadata$twitter, _metadata$twitter2, _metadata$twitter3, _metadata$openGraph6, _metadata$twitter4, _metadata$openGraph7, _metadata$twitter5, _metadata$openGraph8;
15
15
  var _useSiteStore = useSiteStore(function (s) {
16
16
  return [siteSelectors.siteTitle(s), siteSelectors.siteDesc(s), siteSelectors.logo(s), siteSelectors.hostname(s)];
@@ -27,6 +27,9 @@ var Og = /*#__PURE__*/memo(function () {
27
27
  }), /*#__PURE__*/_jsx("meta", {
28
28
  content: (metadata === null || metadata === void 0 ? void 0 : metadata.description) || desc,
29
29
  name: "description"
30
+ }), /*#__PURE__*/_jsx("link", {
31
+ href: hostname || location.origin,
32
+ rel: "canonical"
30
33
  }), /*#__PURE__*/_jsx("meta", {
31
34
  content: (metadata === null || metadata === void 0 || (_metadata$openGraph = metadata.openGraph) === null || _metadata$openGraph === void 0 ? void 0 : _metadata$openGraph.title) || title,
32
35
  property: "og:title"
@@ -34,7 +37,7 @@ var Og = /*#__PURE__*/memo(function () {
34
37
  content: (metadata === null || metadata === void 0 || (_metadata$openGraph2 = metadata.openGraph) === null || _metadata$openGraph2 === void 0 ? void 0 : _metadata$openGraph2.description) || desc,
35
38
  property: "og:description"
36
39
  }), /*#__PURE__*/_jsx("meta", {
37
- content: hostname || location.origin,
40
+ content: urlJoin(hostname || location.origin, location.pathname),
38
41
  property: "og:url"
39
42
  }), /*#__PURE__*/_jsx("meta", {
40
43
  content: metadata === null || metadata === void 0 || (_metadata$openGraph3 = metadata.openGraph) === null || _metadata$openGraph3 === void 0 ? void 0 : _metadata$openGraph3.siteName,
@@ -71,5 +74,5 @@ var Og = /*#__PURE__*/memo(function () {
71
74
  name: "twitter:image"
72
75
  })]
73
76
  });
74
- });
77
+ };
75
78
  export default Og;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ declare const StructuredData: FC;
3
+ export default StructuredData;
@@ -0,0 +1,106 @@
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; }
7
+ import { Helmet } from 'dumi';
8
+ import isEqual from 'fast-deep-equal';
9
+ import urlJoin from 'url-join';
10
+ import { siteSelectors, useSiteStore } from "../../../store";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ var date = new Date().toISOString();
13
+ var StructuredData = function StructuredData() {
14
+ var _metadata$twitter, _metadata$openGraph, _metadata$twitter2, _metadata$openGraph2, _metadata$twitter3, _metadata$openGraph3;
15
+ var _useSiteStore = useSiteStore(function (s) {
16
+ return [siteSelectors.siteTitle(s), siteSelectors.siteDesc(s), siteSelectors.logo(s), siteSelectors.hostname(s)];
17
+ }),
18
+ _useSiteStore2 = _slicedToArray(_useSiteStore, 4),
19
+ title = _useSiteStore2[0],
20
+ desc = _useSiteStore2[1],
21
+ logo = _useSiteStore2[2],
22
+ hostname = _useSiteStore2[3];
23
+ var metadata = useSiteStore(siteSelectors.metadata, isEqual);
24
+ var host = hostname || location.origin;
25
+ var ld = {
26
+ '@context': 'https://schema.org',
27
+ '@graph': [{
28
+ '@id': urlJoin(host, '#website'),
29
+ '@type': 'WebSite',
30
+ 'description': desc,
31
+ 'inLanguage': 'en-US',
32
+ 'name': 'LobeHub',
33
+ 'publisher': {
34
+ '@id': urlJoin(host, '#organization')
35
+ },
36
+ 'url': host
37
+ }, {
38
+ '@id': host,
39
+ '@type': 'WebPage',
40
+ 'about': {
41
+ '@id': urlJoin(host, '#organization')
42
+ },
43
+ 'dateModified': date,
44
+ 'datePublished': date,
45
+ 'description': desc,
46
+ 'image': {
47
+ '@id': urlJoin(host, '#primaryimage')
48
+ },
49
+ 'inLanguage': 'en-US',
50
+ 'isPartOf': {
51
+ '@id': urlJoin(host, '#website')
52
+ },
53
+ 'name': title,
54
+ 'primaryImageOfPage': {
55
+ '@id': urlJoin(host, '#primaryimage')
56
+ },
57
+ 'thumbnailUrl': (metadata === null || metadata === void 0 || (_metadata$twitter = metadata.twitter) === null || _metadata$twitter === void 0 ? void 0 : _metadata$twitter.image) || (metadata === null || metadata === void 0 || (_metadata$openGraph = metadata.openGraph) === null || _metadata$openGraph === void 0 ? void 0 : _metadata$openGraph.image)
58
+ }, {
59
+ '@id': urlJoin(host, '#primaryimage'),
60
+ '@type': 'ImageObject',
61
+ 'contentUrl': (metadata === null || metadata === void 0 || (_metadata$twitter2 = metadata.twitter) === null || _metadata$twitter2 === void 0 ? void 0 : _metadata$twitter2.image) || (metadata === null || metadata === void 0 || (_metadata$openGraph2 = metadata.openGraph) === null || _metadata$openGraph2 === void 0 ? void 0 : _metadata$openGraph2.image) || logo,
62
+ 'inLanguage': 'en-US',
63
+ 'url': (metadata === null || metadata === void 0 || (_metadata$twitter3 = metadata.twitter) === null || _metadata$twitter3 === void 0 ? void 0 : _metadata$twitter3.image) || (metadata === null || metadata === void 0 || (_metadata$openGraph3 = metadata.openGraph) === null || _metadata$openGraph3 === void 0 ? void 0 : _metadata$openGraph3.image) || logo
64
+ }, {
65
+ '@id': urlJoin(host, '#organization'),
66
+ '@type': 'Organization',
67
+ 'alternateName': 'LobeHub',
68
+ 'contactPoint': {
69
+ '@type': 'ContactPoint',
70
+ 'contactType': 'customer support',
71
+ 'email': 'support@lobehub.com'
72
+ },
73
+ 'description': 'We are a group of e/acc design-engineers, hoping to provide modern design components and tools for AIGC, and creating a technology-driven forum, fostering knowledge interaction and the exchange of ideas that may culminate in mutual inspiration and collaborative innovation.',
74
+ 'email': 'hello@lobehub.com',
75
+ 'founders': [{
76
+ '@type': 'Person',
77
+ 'name': 'Arvin Xu',
78
+ 'url': 'https://github.com/arvinxx'
79
+ }, {
80
+ '@type': 'Person',
81
+ 'name': 'CanisMinor',
82
+ 'url': 'https://github.com/arvinxx'
83
+ }],
84
+ 'image': 'https://lobehub.com/icon-512x512.png',
85
+ 'logo': {
86
+ '@type': 'ImageObject',
87
+ 'height': 512,
88
+ 'url': 'https://lobehub.com/icon-512x512.png',
89
+ 'width': 512
90
+ },
91
+ 'name': 'LobeHub',
92
+ 'sameAs': ['https://x.com/lobehub', 'https://github.com/lobehub', 'https://medium.com/@lobehub', 'https://www.youtube.com/@lobehub'],
93
+ 'url': 'https://lobehub.com'
94
+ }]
95
+ };
96
+ return /*#__PURE__*/_jsx(Helmet, {
97
+ children: /*#__PURE__*/_jsx("script", {
98
+ dangerouslySetInnerHTML: {
99
+ __html: JSON.stringify(ld)
100
+ },
101
+ id: "structured-data",
102
+ type: "application/ld+json"
103
+ })
104
+ });
105
+ };
106
+ export default StructuredData;
@@ -6,6 +6,7 @@ import { Provider, createStore as _createStore } from "../../store";
6
6
  import DocumentLayout from "./DocumentLayout";
7
7
  import Favicons from "./Head/Favicons";
8
8
  import Og from "./Head/Og";
9
+ import StructuredData from "./Head/StructuredData";
9
10
  import ThemeProvider from "./ThemeProvider";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -15,7 +16,7 @@ var App = /*#__PURE__*/memo(function (_ref) {
15
16
  createStore: function createStore() {
16
17
  return _createStore(initState);
17
18
  },
18
- children: [/*#__PURE__*/_jsx(Favicons, {}), /*#__PURE__*/_jsx(Og, {}), /*#__PURE__*/_jsx(Analytics, {}), /*#__PURE__*/_jsx(StoreUpdater, {}), /*#__PURE__*/_jsx(ThemeProvider, {
19
+ children: [/*#__PURE__*/_jsx(Favicons, {}), /*#__PURE__*/_jsx(Og, {}), /*#__PURE__*/_jsx(StructuredData, {}), /*#__PURE__*/_jsx(Analytics, {}), /*#__PURE__*/_jsx(StoreUpdater, {}), /*#__PURE__*/_jsx(ThemeProvider, {
19
20
  children: /*#__PURE__*/_jsx(DocumentLayout, {})
20
21
  })]
21
22
  });
@@ -6,8 +6,8 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { SearchBar as Input } from '@lobehub/ui';
8
8
  import { useSiteSearch } from 'dumi';
9
- import SearchResult from 'dumi/theme-default/slots/SearchResult';
10
9
  import { memo, useState } from 'react';
10
+ import SearchResult from "dumi/theme/slots/SearchResult";
11
11
  import { useStyles } from "./style";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -0,0 +1,9 @@
1
+ import { type useSiteSearch } from 'dumi';
2
+ import React from 'react';
3
+ type ISearchResult = ReturnType<typeof useSiteSearch>['result'];
4
+ declare const SearchResult: React.NamedExoticComponent<{
5
+ data: import("dumi/dist/client/theme-api/useSiteSearch").ISearchResult;
6
+ loading: boolean;
7
+ onItemSelect?: ((item: ISearchResult[0]['hints'][0]) => void) | undefined;
8
+ }>;
9
+ export default SearchResult;
@@ -0,0 +1,255 @@
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 _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; } }
4
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
+ 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); }
7
+ 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; }
8
+ import { Icon } from '@lobehub/ui';
9
+ import animateScrollTo from 'animated-scroll-to';
10
+ import { Empty, Typography } from 'antd';
11
+ import { useTheme } from 'antd-style';
12
+ import { FormattedMessage, Link, history, useLocation } from 'dumi';
13
+ import { FileBox, FileIcon, HeadingIcon, LetterText } from 'lucide-react';
14
+ import React, { Fragment, memo, useCallback, useEffect, useState } from 'react';
15
+ import { Center, Flexbox } from 'react-layout-kit';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { Fragment as _Fragment } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ var ICONS_MAPPING = {
20
+ content: LetterText,
21
+ demo: FileBox,
22
+ page: FileIcon,
23
+ title: HeadingIcon
24
+ };
25
+ var Highlight = /*#__PURE__*/memo(function (props) {
26
+ return /*#__PURE__*/_jsx(_Fragment, {
27
+ children: props.texts.map(function (text, idx) {
28
+ return /*#__PURE__*/_jsx(Fragment, {
29
+ children: text.highlighted ? /*#__PURE__*/_jsx("mark", {
30
+ children: text.text
31
+ }) : text.text
32
+ }, idx);
33
+ })
34
+ });
35
+ });
36
+ var useFlatSearchData = function useFlatSearchData(data) {
37
+ var update = useCallback(function () {
38
+ var activeIndex = 0;
39
+ var ret = [];
40
+ var _iterator = _createForOfIteratorHelper(data),
41
+ _step;
42
+ try {
43
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
44
+ var _item = _step.value;
45
+ if (_item.title) {
46
+ ret.push({
47
+ type: 'title',
48
+ value: {
49
+ title: _item.title
50
+ }
51
+ });
52
+ }
53
+ var _iterator2 = _createForOfIteratorHelper(_item.hints),
54
+ _step2;
55
+ try {
56
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
57
+ var hint = _step2.value;
58
+ ret.push({
59
+ activeIndex: activeIndex++,
60
+ type: 'hint',
61
+ value: hint
62
+ });
63
+ }
64
+ } catch (err) {
65
+ _iterator2.e(err);
66
+ } finally {
67
+ _iterator2.f();
68
+ }
69
+ }
70
+ } catch (err) {
71
+ _iterator.e(err);
72
+ } finally {
73
+ _iterator.f();
74
+ }
75
+ return [ret, activeIndex];
76
+ }, [data]);
77
+ var _useState = useState(update),
78
+ _useState2 = _slicedToArray(_useState, 2),
79
+ flatData = _useState2[0],
80
+ setFlatData = _useState2[1];
81
+ useEffect(function () {
82
+ setFlatData(update);
83
+ }, [data]);
84
+ return flatData;
85
+ };
86
+ var SearchResult = /*#__PURE__*/memo(function (props) {
87
+ var theme = useTheme();
88
+ var _useFlatSearchData = useFlatSearchData(props.data),
89
+ _useFlatSearchData2 = _slicedToArray(_useFlatSearchData, 2),
90
+ data = _useFlatSearchData2[0],
91
+ histsCount = _useFlatSearchData2[1];
92
+ var _useState3 = useState(-1),
93
+ _useState4 = _slicedToArray(_useState3, 2),
94
+ activeIndex = _useState4[0],
95
+ setActiveIndex = _useState4[1];
96
+ var _useLocation = useLocation(),
97
+ pathname = _useLocation.pathname;
98
+ var onItemSelect = function onItemSelect(item) {
99
+ var _props$onItemSelect;
100
+ (_props$onItemSelect = props.onItemSelect) === null || _props$onItemSelect === void 0 || _props$onItemSelect.call(props, item);
101
+ var url = new URL(item === null || item === void 0 ? void 0 : item.link, location.origin);
102
+ if ((url === null || url === void 0 ? void 0 : url.pathname) === pathname && !url.hash) {
103
+ setTimeout(function () {
104
+ animateScrollTo(0, {
105
+ maxDuration: 300
106
+ });
107
+ }, 1);
108
+ }
109
+ };
110
+ useEffect(function () {
111
+ var handler = function handler(ev) {
112
+ // TODO: scroll into view for invisible items
113
+ if (ev.key === 'ArrowDown') {
114
+ setActiveIndex((activeIndex + 1) % histsCount);
115
+ } else if (ev.key === 'ArrowUp') {
116
+ setActiveIndex((activeIndex + histsCount - 1) % histsCount);
117
+ } else if (ev.key === 'Enter' && activeIndex >= 0) {
118
+ var _item2 = data.find(function (item) {
119
+ return item.type === 'hint' && item.activeIndex === activeIndex;
120
+ }).value;
121
+ history.push(_item2.link);
122
+ onItemSelect === null || onItemSelect === void 0 || onItemSelect(_item2);
123
+ document.activeElement.blur();
124
+ }
125
+ if (['Escape', 'Enter'].includes(ev.key)) {
126
+ setActiveIndex(-1);
127
+ }
128
+ };
129
+ document.addEventListener('keydown', handler);
130
+ return function () {
131
+ return document.removeEventListener('keydown', handler);
132
+ };
133
+ });
134
+ var returnNode = null;
135
+ if (props.loading) {
136
+ returnNode = /*#__PURE__*/_jsx(Empty, {
137
+ description: /*#__PURE__*/_jsx(FormattedMessage, {
138
+ id: "search.loading"
139
+ }),
140
+ image: Empty.PRESENTED_IMAGE_SIMPLE
141
+ });
142
+ } else if (props.data.length > 0) {
143
+ returnNode = /*#__PURE__*/_jsx(Flexbox, {
144
+ gap: 8,
145
+ paddingBlock: 8,
146
+ paddingInline: 8,
147
+ children: data.map(function (item, i) {
148
+ return item.type === 'title' ? /*#__PURE__*/_jsx(Flexbox, {
149
+ paddingBlock: 8,
150
+ paddingInline: 12,
151
+ style: {
152
+ background: theme.colorFillTertiary,
153
+ borderRadius: theme.borderRadius
154
+ },
155
+ children: /*#__PURE__*/_jsx(Typography.Title, {
156
+ ellipsis: {
157
+ rows: 1
158
+ },
159
+ level: 4,
160
+ style: {
161
+ fontSize: 14,
162
+ lineHeight: 1.4,
163
+ margin: 0
164
+ },
165
+ children: item.value.title
166
+ })
167
+ }, String(i)) : /*#__PURE__*/_jsx(Flexbox, {
168
+ children: /*#__PURE__*/_jsx(Link, {
169
+ "data-active": activeIndex === item.activeIndex || undefined,
170
+ onClick: function onClick() {
171
+ return onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item.value);
172
+ },
173
+ style: {
174
+ color: 'inherit'
175
+ },
176
+ to: item.value.link,
177
+ children: /*#__PURE__*/_jsxs(Flexbox, {
178
+ align: 'center',
179
+ gap: 16,
180
+ horizontal: true,
181
+ style: {
182
+ overflow: 'hidden',
183
+ position: 'relative'
184
+ },
185
+ children: [/*#__PURE__*/_jsx(Center, {
186
+ flex: 'none',
187
+ height: 48,
188
+ style: {
189
+ background: theme.colorFillTertiary,
190
+ borderRadius: theme.borderRadius
191
+ },
192
+ width: 48,
193
+ children: /*#__PURE__*/_jsx(Icon, {
194
+ color: theme.colorTextDescription,
195
+ icon: ICONS_MAPPING === null || ICONS_MAPPING === void 0 ? void 0 : ICONS_MAPPING[item.value.type],
196
+ size: {
197
+ fontSize: 32
198
+ }
199
+ })
200
+ }), /*#__PURE__*/_jsxs(Flexbox, {
201
+ children: [/*#__PURE__*/_jsx(Typography.Title, {
202
+ ellipsis: {
203
+ rows: 1
204
+ },
205
+ level: 4,
206
+ style: {
207
+ fontSize: 14,
208
+ lineHeight: 1.4,
209
+ margin: 0
210
+ },
211
+ children: /*#__PURE__*/_jsx(Highlight, {
212
+ texts: item.value.highlightTitleTexts
213
+ })
214
+ }), /*#__PURE__*/_jsx(Typography.Paragraph, {
215
+ ellipsis: {
216
+ rows: 2
217
+ },
218
+ style: {
219
+ color: theme.colorTextSecondary,
220
+ fontSize: 12,
221
+ lineHeight: 1.4,
222
+ margin: 0
223
+ },
224
+ children: /*#__PURE__*/_jsx(Highlight, {
225
+ texts: item.value.highlightTexts
226
+ })
227
+ })]
228
+ })]
229
+ })
230
+ })
231
+ }, String(i));
232
+ })
233
+ });
234
+ } else {
235
+ returnNode = /*#__PURE__*/_jsx(Empty, {
236
+ description: /*#__PURE__*/_jsx(FormattedMessage, {
237
+ id: "search.not.found"
238
+ }),
239
+ image: Empty.PRESENTED_IMAGE_SIMPLE
240
+ });
241
+ }
242
+ return /*#__PURE__*/_jsx(Flexbox, {
243
+ onMouseDownCapture: function onMouseDownCapture(ev) {
244
+ return ev.preventDefault();
245
+ },
246
+ onMouseEnter: function onMouseEnter() {
247
+ return setActiveIndex(-1);
248
+ },
249
+ onMouseUpCapture: function onMouseUpCapture() {
250
+ document.activeElement.blur();
251
+ },
252
+ children: returnNode
253
+ });
254
+ });
255
+ export default SearchResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi-theme-lobehub",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "description": "dumi-theme-lobehub is a documentation site theme package designed for dumi2. It provides a more beautiful and user-friendly development and reading experience based on @lobehub/ui",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -27,6 +27,7 @@
27
27
  "dependencies": {
28
28
  "@floating-ui/react": "^0.26.28",
29
29
  "ahooks": "^3.8.1",
30
+ "animated-scroll-to": "^2.3.0",
30
31
  "chalk": "^4.1.2",
31
32
  "fast-deep-equal": "^3.1.3",
32
33
  "history": "^5.3.0",
@@ -35,6 +36,7 @@
35
36
  "rc-footer": "^0.6.8",
36
37
  "react-layout-kit": "^1.9.0",
37
38
  "swr": "^2.2.5",
39
+ "url-join": "^5.0.0",
38
40
  "use-merge-value": "^1.2.0",
39
41
  "zustand": "^4.5.5",
40
42
  "zustand-utils": "^1.3.2"