diff --git a/docusaurus.config.js b/docusaurus.config.js index d53a0873f..16e710592 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -36,6 +36,7 @@ const config = { customFields: { marketingSite: 'https://zap-hosting.com', + searchSite: 'https://zap-hosting.com' }, // Even if you don't use internalization, you can use this field to set useful @@ -208,12 +209,6 @@ const config = { containerId: 'GTM-5R9FLS69', }, ], - [ - require.resolve('docusaurus-lunr-search'), - { - languages: ['en', 'de'] // language codes - } - ] ], presets: [ diff --git a/package-lock.json b/package-lock.json index 041be66fb..e1e2ab10f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,6 @@ "clsx": "^2.1.1", "cross-spawn": "^7.0.6", "crypto-js": "^4.2.0", - "docusaurus-lunr-search": "^3.6.1", "express": "^5.2.1", "git-url-parse": "^16.1.0", "js-yaml": "^4.1.1", @@ -5919,11 +5918,6 @@ "parse-path": "*" } }, - "node_modules/@types/parse5": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-5.0.3.tgz", - "integrity": "sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw==" - }, "node_modules/@types/prismjs": { "version": "1.26.5", "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.5.tgz", @@ -6222,11 +6216,6 @@ "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" }, - "node_modules/abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" - }, "node_modules/accepts": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", @@ -6490,11 +6479,6 @@ "node": ">= 8" } }, - "node_modules/aproba": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.1.0.tgz", - "integrity": "sha512-tLIEcj5GuR2RSTnxNKdkK0dJ/GrC7P38sUkiDmDuHfsHmbagTFAxDVIBltoklXEVIQ/f14IL8IMJ5pn9Hez1Ew==" - }, "node_modules/arg": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", @@ -6582,14 +6566,6 @@ "node": ">= 4.0.0" } }, - "node_modules/autocomplete.js": { - "version": "0.37.1", - "resolved": "https://registry.npmjs.org/autocomplete.js/-/autocomplete.js-0.37.1.tgz", - "integrity": "sha512-PgSe9fHYhZEsm/9jggbjtVsGXJkPLvd+9mC7gZJ662vVL5CRWEtm/mIrrzCx0MrNxHVwxD5d00UOn6NsmL2LUQ==", - "dependencies": { - "immediate": "^3.2.3" - } - }, "node_modules/autoprefixer": { "version": "10.4.21", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.21.tgz", @@ -6735,15 +6711,6 @@ "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==" }, - "node_modules/bcp-47-match": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-1.0.3.tgz", - "integrity": "sha512-LggQ4YTdjWQSKELZF5JwchnBa1u0pIQSZf5lSdOHEdbVP55h0qICA/FUp3+W99q0xqxYa1ZQizTUH87gecII5w==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", @@ -7331,14 +7298,6 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, - "node_modules/color-support": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", - "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", - "bin": { - "color-support": "bin.js" - } - }, "node_modules/colord": { "version": "2.9.3", "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", @@ -7357,15 +7316,6 @@ "node": ">=10" } }, - "node_modules/comma-separated-tokens": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz", - "integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/commander": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", @@ -7494,11 +7444,6 @@ "node": "^14.18.0 || >=16.10.0" } }, - "node_modules/console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" - }, "node_modules/content-disposition": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", @@ -7942,11 +7887,6 @@ "url": "https://github.com/sponsors/fb55" } }, - "node_modules/css-selector-parser": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/css-selector-parser/-/css-selector-parser-1.4.1.tgz", - "integrity": "sha512-HYPSb7y/Z7BNDCOrakL4raGO2zltZkbeXyAd6Tg9obzix6QhzxCotdBl6VT0Dv4vZfJGVz3WL/xaEI9Ly3ul0g==" - }, "node_modules/css-tree": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", @@ -8875,18 +8815,6 @@ "node": ">=8" } }, - "node_modules/direction": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/direction/-/direction-1.0.4.tgz", - "integrity": "sha512-GYqKi1aH7PJXxdhTeZBFrg8vUBeKXi+cNprXsC1kpJcbcVnV9wBsrOu1cQEdG0WeQwlfHiy3XvnKfIrJ2R0NzQ==", - "bin": { - "direction": "cli.js" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/dns-packet": { "version": "5.6.1", "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.1.tgz", @@ -8898,123 +8826,6 @@ "node": ">=6" } }, - "node_modules/docusaurus-lunr-search": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/docusaurus-lunr-search/-/docusaurus-lunr-search-3.6.1.tgz", - "integrity": "sha512-ms2FWYzR7OrvS2x0/HSPaAenAATrBenGpCwWpjmpK8SnUpqygVPvuss2RG5l2ZuMxpKFP0rhEnEy8Kx4lSQimw==", - "dependencies": { - "autocomplete.js": "^0.37.1", - "clsx": "^2.1.1", - "gauge": "^3.0.2", - "hast-util-select": "^4.0.2", - "hast-util-to-text": "^2.0.1", - "hogan.js": "^3.0.2", - "lunr": "^2.3.9", - "lunr-languages": "^1.4.0", - "mark.js": "^8.11.1", - "minimatch": "^3.1.2", - "rehype-parse": "^7.0.1", - "to-vfile": "^6.1.0", - "unified": "^9.2.2", - "unist-util-is": "^4.1.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "peerDependencies": { - "@docusaurus/core": "^2.0.0-alpha.60 || ^2.0.0 || ^3.0.0", - "react": "^16.8.4 || ^17 || ^18 || ^19", - "react-dom": "^16.8.4 || ^17 || ^18 || ^19" - } - }, - "node_modules/docusaurus-lunr-search/node_modules/@types/unist": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", - "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==" - }, - "node_modules/docusaurus-lunr-search/node_modules/bail": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.5.tgz", - "integrity": "sha512-xFbRxM1tahm08yHBP16MMjVUAvDaBMD38zsM9EMAUN61omwLmKlOpB/Zku5QkjZ8TZ4vn53pj+t518cH0S03RQ==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/docusaurus-lunr-search/node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "engines": { - "node": ">=8" - } - }, - "node_modules/docusaurus-lunr-search/node_modules/trough": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.5.tgz", - "integrity": "sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/docusaurus-lunr-search/node_modules/unified": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.2.tgz", - "integrity": "sha512-Sg7j110mtefBD+qunSLO1lqOEKdrwBFBrR6Qd8f4uwkhWNlbkaqwHse6e7QvD3AP/MNoJdEDLaf8OxYyoWgorQ==", - "dependencies": { - "bail": "^1.0.0", - "extend": "^3.0.0", - "is-buffer": "^2.0.0", - "is-plain-obj": "^2.0.0", - "trough": "^1.0.0", - "vfile": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/docusaurus-lunr-search/node_modules/unist-util-stringify-position": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", - "integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==", - "dependencies": { - "@types/unist": "^2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/docusaurus-lunr-search/node_modules/vfile": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-4.2.1.tgz", - "integrity": "sha512-O6AE4OskCG5S1emQ/4gl8zK586RqA3srz3nfK/Viy0UPToBc5Trp9BVFb1u0CjsKrAWwnpr4ifM/KBXPWwJbCA==", - "dependencies": { - "@types/unist": "^2.0.0", - "is-buffer": "^2.0.0", - "unist-util-stringify-position": "^2.0.0", - "vfile-message": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/docusaurus-lunr-search/node_modules/vfile-message": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz", - "integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-stringify-position": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/dom-converter": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", @@ -10114,44 +9925,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/gauge": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", - "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", - "deprecated": "This package is no longer supported.", - "dependencies": { - "aproba": "^1.0.3 || ^2.0.0", - "color-support": "^1.1.2", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.1", - "object-assign": "^4.1.1", - "signal-exit": "^3.0.0", - "string-width": "^4.2.3", - "strip-ansi": "^6.0.1", - "wide-align": "^1.1.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/gauge/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/gauge/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/generator-function": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz", @@ -10545,11 +10318,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" - }, "node_modules/has-yarn": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-yarn/-/has-yarn-3.0.0.tgz", @@ -10572,95 +10340,6 @@ "node": ">= 0.4" } }, - "node_modules/hast-util-from-parse5": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-6.0.1.tgz", - "integrity": "sha512-jeJUWiN5pSxW12Rh01smtVkZgZr33wBokLzKLwinYOUfSzm1Nl/c3GUGebDyOKjdsRgMvoVbV0VpAcpjF4NrJA==", - "dependencies": { - "@types/parse5": "^5.0.0", - "hastscript": "^6.0.0", - "property-information": "^5.0.0", - "vfile": "^4.0.0", - "vfile-location": "^3.2.0", - "web-namespaces": "^1.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-from-parse5/node_modules/@types/unist": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", - "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==" - }, - "node_modules/hast-util-from-parse5/node_modules/unist-util-stringify-position": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", - "integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==", - "dependencies": { - "@types/unist": "^2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-from-parse5/node_modules/vfile": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-4.2.1.tgz", - "integrity": "sha512-O6AE4OskCG5S1emQ/4gl8zK586RqA3srz3nfK/Viy0UPToBc5Trp9BVFb1u0CjsKrAWwnpr4ifM/KBXPWwJbCA==", - "dependencies": { - "@types/unist": "^2.0.0", - "is-buffer": "^2.0.0", - "unist-util-stringify-position": "^2.0.0", - "vfile-message": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-from-parse5/node_modules/vfile-message": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz", - "integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-stringify-position": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-has-property": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/hast-util-has-property/-/hast-util-has-property-1.0.4.tgz", - "integrity": "sha512-ghHup2voGfgFoHMGnaLHOjbYFACKrRh9KFttdCzMCbFoBMJXiNi2+XTrPP8+q6cDJM/RSqlCfVWrjp1H201rZg==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-is-element": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.1.0.tgz", - "integrity": "sha512-oUmNua0bFbdrD/ELDSSEadRVtWZOf3iF6Lbv81naqsIV99RnSCieTbWuWCY8BAeEfKJTKl0gRdokv+dELutHGQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-parse-selector": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.2.5.tgz", - "integrity": "sha512-7j6mrk/qqkSehsM92wQjdIgWM2/BW61u/53G6xmC8i1OmEdKLHbk419QKQUjz6LglWsfqoiHmyMRkP1BGjecNQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/hast-util-raw": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.1.0.tgz", @@ -10790,63 +10469,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/hast-util-select": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/hast-util-select/-/hast-util-select-4.0.2.tgz", - "integrity": "sha512-8EEG2//bN5rrzboPWD2HdS3ugLijNioS1pqOTIolXNf67xxShYw4SQEmVXd3imiBG+U2bC2nVTySr/iRAA7Cjg==", - "dependencies": { - "bcp-47-match": "^1.0.0", - "comma-separated-tokens": "^1.0.0", - "css-selector-parser": "^1.0.0", - "direction": "^1.0.0", - "hast-util-has-property": "^1.0.0", - "hast-util-is-element": "^1.0.0", - "hast-util-to-string": "^1.0.0", - "hast-util-whitespace": "^1.0.0", - "not": "^0.1.0", - "nth-check": "^2.0.0", - "property-information": "^5.0.0", - "space-separated-tokens": "^1.0.0", - "unist-util-visit": "^2.0.0", - "zwitch": "^1.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-select/node_modules/@types/unist": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", - "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==" - }, - "node_modules/hast-util-select/node_modules/unist-util-visit": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", - "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-select/node_modules/unist-util-visit-parents": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz", - "integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/hast-util-to-estree": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/hast-util-to-estree/-/hast-util-to-estree-3.1.3.tgz", @@ -11050,67 +10672,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/hast-util-to-string": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/hast-util-to-string/-/hast-util-to-string-1.0.4.tgz", - "integrity": "sha512-eK0MxRX47AV2eZ+Lyr18DCpQgodvaS3fAQO2+b9Two9F5HEoRPhiUMNzoXArMJfZi2yieFzUBMRl3HNJ3Jus3w==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-to-text": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-2.0.1.tgz", - "integrity": "sha512-8nsgCARfs6VkwH2jJU9b8LNTuR4700na+0h3PqCaEk4MAnMDeu5P0tP8mjk9LLNGxIeQRLbiDbZVw6rku+pYsQ==", - "dependencies": { - "hast-util-is-element": "^1.0.0", - "repeat-string": "^1.0.0", - "unist-util-find-after": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hast-util-whitespace": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.4.tgz", - "integrity": "sha512-I5GTdSfhYfAPNztx2xJRQpG8cuDSNt599/7YUn7Gx/WxNMsG+a835k97TDkFgk123cwjfwINaZknkKkphx/f2A==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hastscript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-6.0.0.tgz", - "integrity": "sha512-nDM6bvd7lIqDUiYEiu5Sl/+6ReP0BMk/2f4U/Rooccxkj0P5nm+acM5PrGJ/t5I8qPGiqZSE6hVAwZEdZIvP4w==", - "dependencies": { - "@types/hast": "^2.0.0", - "comma-separated-tokens": "^1.0.0", - "hast-util-parse-selector": "^2.0.0", - "property-information": "^5.0.0", - "space-separated-tokens": "^1.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hastscript/node_modules/@types/hast": { - "version": "2.3.10", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.10.tgz", - "integrity": "sha512-McWspRw8xx8J9HurkVBfYj0xKoE25tOFlHGdx4MJ5xORQrMGZNqJhVQWaIbm6Oyla5kYOXtDiopzKRJzEOkwJw==", - "dependencies": { - "@types/unist": "^2" - } - }, - "node_modules/hastscript/node_modules/@types/unist": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", - "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==" - }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -11132,18 +10693,6 @@ "value-equal": "^1.0.1" } }, - "node_modules/hogan.js": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/hogan.js/-/hogan.js-3.0.2.tgz", - "integrity": "sha512-RqGs4wavGYJWE07t35JQccByczmNUXQT0E12ZYV1VKYu5UiAU9lsos/yBAcf840+zrUQQxgVduCR5/B8nNtibg==", - "dependencies": { - "mkdirp": "0.3.0", - "nopt": "1.0.10" - }, - "bin": { - "hulk": "bin/hulk" - } - }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -11493,11 +11042,6 @@ "node": ">=16.x" } }, - "node_modules/immediate": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz", - "integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==" - }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", @@ -11711,28 +11255,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-buffer": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", - "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "engines": { - "node": ">=4" - } - }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -12906,16 +12428,6 @@ "yallist": "^3.0.2" } }, - "node_modules/lunr": { - "version": "2.3.9", - "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", - "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==" - }, - "node_modules/lunr-languages": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/lunr-languages/-/lunr-languages-1.14.0.tgz", - "integrity": "sha512-hWUAb2KqM3L7J5bcrngszzISY4BxrXn/Xhbb9TTCJYEGqlR1nG67/M14sp09+PTIRklobrn57IAxcdcO/ZFyNA==" - }, "node_modules/magic-string": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", @@ -12924,11 +12436,6 @@ "sourcemap-codec": "^1.4.8" } }, - "node_modules/mark.js": { - "version": "8.11.1", - "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz", - "integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==" - }, "node_modules/markdown-extensions": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-2.0.0.tgz", @@ -15268,15 +14775,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/mkdirp": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", - "integrity": "sha512-OHsdUcVAQ6pOtg5JYWpCBo9W/GySVuwvP9hueRMW7UqshC0tbfzLv8wjySTPm3tfUZ/21CE9E1pJagOA91Pxew==", - "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", - "engines": { - "node": "*" - } - }, "node_modules/mlly": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.0.tgz", @@ -15394,20 +14892,6 @@ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==" }, - "node_modules/nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -15435,11 +14919,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/not": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/not/-/not-0.1.0.tgz", - "integrity": "sha512-5PDmaAsVfnWUgTUbJ3ERwn7u79Z0dYxN9ErxCpVJJqe2RK0PJ3z+iFUxuqjwtlDDegXvtWoxD/3Fzxox7tFGWA==" - }, "node_modules/npm-run-path": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", @@ -17520,18 +16999,6 @@ "react-is": "^16.13.1" } }, - "node_modules/property-information": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/property-information/-/property-information-5.6.0.tgz", - "integrity": "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA==", - "dependencies": { - "xtend": "^4.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/proto-list": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", @@ -18090,24 +17557,6 @@ "regjsparser": "bin/parser" } }, - "node_modules/rehype-parse": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-7.0.1.tgz", - "integrity": "sha512-fOiR9a9xH+Le19i4fGzIEowAbwG7idy2Jzs4mOrFWBSJ0sNUgy0ev871dwWnbOo371SjgjG4pwzrbgSVrKxecw==", - "dependencies": { - "hast-util-from-parse5": "^6.0.0", - "parse5": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/rehype-parse/node_modules/parse5": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", - "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==" - }, "node_modules/rehype-raw": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz", @@ -19240,15 +18689,6 @@ "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", "deprecated": "Please use @jridgewell/sourcemap-codec instead" }, - "node_modules/space-separated-tokens": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz", - "integrity": "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/spdy": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/spdy/-/spdy-4.0.2.tgz", @@ -19854,64 +19294,6 @@ "node": ">=8.0" } }, - "node_modules/to-vfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-6.1.0.tgz", - "integrity": "sha512-BxX8EkCxOAZe+D/ToHdDsJcVI4HqQfmw0tCkp31zf3dNP/XWIAjU4CmeuSwsSoOzOTqHPOL0KUzyZqJplkD0Qw==", - "dependencies": { - "is-buffer": "^2.0.0", - "vfile": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/to-vfile/node_modules/@types/unist": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", - "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==" - }, - "node_modules/to-vfile/node_modules/unist-util-stringify-position": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", - "integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==", - "dependencies": { - "@types/unist": "^2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/to-vfile/node_modules/vfile": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-4.2.1.tgz", - "integrity": "sha512-O6AE4OskCG5S1emQ/4gl8zK586RqA3srz3nfK/Viy0UPToBc5Trp9BVFb1u0CjsKrAWwnpr4ifM/KBXPWwJbCA==", - "dependencies": { - "@types/unist": "^2.0.0", - "is-buffer": "^2.0.0", - "unist-util-stringify-position": "^2.0.0", - "vfile-message": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/to-vfile/node_modules/vfile-message": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz", - "integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==", - "dependencies": { - "@types/unist": "^2.0.0", - "unist-util-stringify-position": "^2.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/toggle-selection": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", @@ -20192,27 +19574,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/unist-util-find-after": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-3.0.0.tgz", - "integrity": "sha512-ojlBqfsBftYXExNu3+hHLfJQ/X1jYY/9vdm4yZWjIbf0VuWF6CRufci1ZyoD/wV2TYMKxXUoNuoqwy+CkgzAiQ==", - "dependencies": { - "unist-util-is": "^4.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-is": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.1.0.tgz", - "integrity": "sha512-ZOQSsnce92GrxSqlnEEseX0gi7GH9zTJZ0p9dtu87WRb/37mMPO2Ilx1s/t9vBHrFhbgweUwb+t7cIn5dxPhZg==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/unist-util-position": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", @@ -20594,15 +19955,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/vfile-location": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.2.0.tgz", - "integrity": "sha512-aLEIZKv/oxuCDZ8lkJGhuhztf/BW4M+iHdCwglA/eWc+vtuRFJj8EtgceYFX4LRjOhCAAiNHsKGssC6onJ+jbA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/vfile-message": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz", @@ -20679,15 +20031,6 @@ "minimalistic-assert": "^1.0.0" } }, - "node_modules/web-namespaces": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-1.1.4.tgz", - "integrity": "sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/webidl-conversions": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", @@ -21440,32 +20783,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/wide-align": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", - "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", - "dependencies": { - "string-width": "^1.0.2 || 2 || 3 || 4" - } - }, - "node_modules/wide-align/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/wide-align/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/widest-line": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-4.0.1.tgz", @@ -21824,14 +21141,6 @@ "xml-js": "bin/cli.js" } }, - "node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "engines": { - "node": ">=0.4" - } - }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", @@ -21855,15 +21164,6 @@ "funding": { "url": "https://github.com/sponsors/colinhacks" } - }, - "node_modules/zwitch": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-1.0.5.tgz", - "integrity": "sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } } } } diff --git a/package.json b/package.json index 945733d60..197444096 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "clsx": "^2.1.1", "cross-spawn": "^7.0.6", "crypto-js": "^4.2.0", - "docusaurus-lunr-search": "^3.6.1", "express": "^5.2.1", "git-url-parse": "^16.1.0", "js-yaml": "^4.1.1", diff --git a/src/theme/SearchBar/DocSearch.js b/src/theme/SearchBar/DocSearch.js deleted file mode 100644 index 77a53de99..000000000 --- a/src/theme/SearchBar/DocSearch.js +++ /dev/null @@ -1,310 +0,0 @@ -import Hogan from "hogan.js"; -import LunrSearchAdapter from "./lunar-search"; -import autocomplete from "autocomplete.js"; -import templates from "./templates"; -import utils from "./utils"; -import $ from "autocomplete.js/zepto"; - -class DocSearch { - constructor({ - searchDocs, - searchIndex, - inputSelector, - debug = false, - baseUrl = '/', - queryDataCallback = null, - autocompleteOptions = { - debug: false, - hint: false, - autoselect: true - }, - transformData = false, - queryHook = false, - handleSelected = false, - enhancedSearchInput = false, - layout = "column", - maxHits = 5 - }) { - this.input = DocSearch.getInputFromSelector(inputSelector); - this.queryDataCallback = queryDataCallback || null; - const autocompleteOptionsDebug = - autocompleteOptions && autocompleteOptions.debug - ? autocompleteOptions.debug - : false; - // eslint-disable-next-line no-param-reassign - autocompleteOptions.debug = debug || autocompleteOptionsDebug; - this.autocompleteOptions = autocompleteOptions; - this.autocompleteOptions.cssClasses = - this.autocompleteOptions.cssClasses || {}; - this.autocompleteOptions.cssClasses.prefix = - this.autocompleteOptions.cssClasses.prefix || "ds"; - const inputAriaLabel = - this.input && - typeof this.input.attr === "function" && - this.input.attr("aria-label"); - this.autocompleteOptions.ariaLabel = - this.autocompleteOptions.ariaLabel || inputAriaLabel || "search input"; - - this.isSimpleLayout = layout === "simple"; - - this.client = new LunrSearchAdapter(searchDocs, searchIndex, baseUrl, maxHits); - - if (enhancedSearchInput) { - this.input = DocSearch.injectSearchBox(this.input); - } - this.autocomplete = autocomplete(this.input, autocompleteOptions, [ - { - source: this.getAutocompleteSource(transformData, queryHook), - templates: { - suggestion: DocSearch.getSuggestionTemplate(this.isSimpleLayout), - footer: templates.footer, - empty: DocSearch.getEmptyTemplate() - } - } - ]); - - const customHandleSelected = handleSelected; - this.handleSelected = customHandleSelected || this.handleSelected; - - // We prevent default link clicking if a custom handleSelected is defined - if (customHandleSelected) { - $(".algolia-autocomplete").on("click", ".ds-suggestions a", event => { - event.preventDefault(); - }); - } - - this.autocomplete.on( - "autocomplete:selected", - this.handleSelected.bind(null, this.autocomplete.autocomplete) - ); - - this.autocomplete.on( - "autocomplete:shown", - this.handleShown.bind(null, this.input) - ); - - if (enhancedSearchInput) { - DocSearch.bindSearchBoxEvent(); - } - - // Ctrl/Cmd + K should focus the search bar, emulating the Algolia search UI - document.addEventListener('keydown', (e) => { - if ((e.ctrlKey || e.metaKey) && e.key == 'k') { - this.input.focus(); - - // By default, using Ctrl + K in Chrome will open the location bar, so disable this - e.preventDefault(); - } - }); - } - - static injectSearchBox(input) { - input.before(templates.searchBox); - const newInput = input - .prev() - .prev() - .find("input"); - input.remove(); - return newInput; - } - - static bindSearchBoxEvent() { - $('.searchbox [type="reset"]').on("click", function () { - $("input#docsearch").focus(); - $(this).addClass("hide"); - autocomplete.autocomplete.setVal(""); - }); - - $("input#docsearch").on("keyup", () => { - const searchbox = document.querySelector("input#docsearch"); - const reset = document.querySelector('.searchbox [type="reset"]'); - reset.className = "searchbox__reset"; - if (searchbox.value.length === 0) { - reset.className += " hide"; - } - }); - } - - /** - * Returns the matching input from a CSS selector, null if none matches - * @function getInputFromSelector - * @param {string} selector CSS selector that matches the search - * input of the page - * @returns {void} - */ - static getInputFromSelector(selector) { - const input = $(selector).filter("input"); - return input.length ? $(input[0]) : null; - } - - /** - * Returns the `source` method to be passed to autocomplete.js. It will query - * the Algolia index and call the callbacks with the formatted hits. - * @function getAutocompleteSource - * @param {function} transformData An optional function to transform the hits - * @param {function} queryHook An optional function to transform the query - * @returns {function} Method to be passed as the `source` option of - * autocomplete - */ - getAutocompleteSource(transformData, queryHook) { - return (query, callback) => { - if (queryHook) { - // eslint-disable-next-line no-param-reassign - query = queryHook(query) || query; - } - this.client.search(query).then(hits => { - if ( - this.queryDataCallback && - typeof this.queryDataCallback == "function" - ) { - this.queryDataCallback(hits); - } - if (transformData) { - hits = transformData(hits) || hits; - } - callback(DocSearch.formatHits(hits)); - }); - }; - } - - // Given a list of hits returned by the API, will reformat them to be used in - // a Hogan template - static formatHits(receivedHits) { - const clonedHits = utils.deepClone(receivedHits); - const hits = clonedHits.map(hit => { - if (hit._highlightResult) { - // eslint-disable-next-line no-param-reassign - hit._highlightResult = utils.mergeKeyWithParent( - hit._highlightResult, - "hierarchy" - ); - } - return utils.mergeKeyWithParent(hit, "hierarchy"); - }); - - // Group hits by category / subcategory - let groupedHits = utils.groupBy(hits, "lvl0"); - $.each(groupedHits, (level, collection) => { - const groupedHitsByLvl1 = utils.groupBy(collection, "lvl1"); - const flattenedHits = utils.flattenAndFlagFirst( - groupedHitsByLvl1, - "isSubCategoryHeader" - ); - groupedHits[level] = flattenedHits; - }); - groupedHits = utils.flattenAndFlagFirst(groupedHits, "isCategoryHeader"); - - // Translate hits into smaller objects to be send to the template - return groupedHits.map(hit => { - const url = DocSearch.formatURL(hit); - const category = utils.getHighlightedValue(hit, "lvl0"); - const subcategory = utils.getHighlightedValue(hit, "lvl1") || category; - const displayTitle = utils - .compact([ - utils.getHighlightedValue(hit, "lvl2") || subcategory, - utils.getHighlightedValue(hit, "lvl3"), - utils.getHighlightedValue(hit, "lvl4"), - utils.getHighlightedValue(hit, "lvl5"), - utils.getHighlightedValue(hit, "lvl6") - ]) - .join( - ' › ' - ); - const text = utils.getSnippetedValue(hit, "content"); - const isTextOrSubcategoryNonEmpty = - (subcategory && subcategory !== "") || - (displayTitle && displayTitle !== ""); - const isLvl1EmptyOrDuplicate = - !subcategory || subcategory === "" || subcategory === category; - const isLvl2 = - displayTitle && displayTitle !== "" && displayTitle !== subcategory; - const isLvl1 = - !isLvl2 && - (subcategory && subcategory !== "" && subcategory !== category); - const isLvl0 = !isLvl1 && !isLvl2; - const version = hit.version; - - return { - isLvl0, - isLvl1, - isLvl2, - isLvl1EmptyOrDuplicate, - isCategoryHeader: hit.isCategoryHeader, - isSubCategoryHeader: hit.isSubCategoryHeader, - isTextOrSubcategoryNonEmpty, - category, - subcategory, - title: displayTitle, - text, - url, - version - }; - }); - } - - static formatURL(hit) { - const { url, anchor } = hit; - if (url) { - const containsAnchor = url.indexOf("#") !== -1; - if (containsAnchor) return url; - else if (anchor) return `${hit.url}#${hit.anchor}`; - return url; - } else if (anchor) return `#${hit.anchor}`; - /* eslint-disable */ - console.warn("no anchor nor url for : ", JSON.stringify(hit)); - /* eslint-enable */ - return null; - } - - static getEmptyTemplate() { - return args => Hogan.compile(templates.empty).render(args); - } - - static getSuggestionTemplate(isSimpleLayout) { - const stringTemplate = isSimpleLayout - ? templates.suggestionSimple - : templates.suggestion; - const template = Hogan.compile(stringTemplate); - return suggestion => template.render(suggestion); - } - - handleSelected(input, event, suggestion, datasetNumber, context = {}) { - // Do nothing if click on the suggestion, as it's already a , the - // browser will take care of it. This allow Ctrl-Clicking on results and not - // having the main window being redirected as well - if (context.selectionMethod === "click") { - return; - } - - input.setVal(""); - window.location.assign(suggestion.url); - } - - handleShown(input) { - const middleOfInput = input.offset().left + input.width() / 2; - let middleOfWindow = $(document).width() / 2; - - if (isNaN(middleOfWindow)) { - middleOfWindow = 900; - } - - const alignClass = - middleOfInput - middleOfWindow >= 0 - ? "algolia-autocomplete-right" - : "algolia-autocomplete-left"; - const otherAlignClass = - middleOfInput - middleOfWindow < 0 - ? "algolia-autocomplete-right" - : "algolia-autocomplete-left"; - const autocompleteWrapper = $(".algolia-autocomplete"); - if (!autocompleteWrapper.hasClass(alignClass)) { - autocompleteWrapper.addClass(alignClass); - } - - if (autocompleteWrapper.hasClass(otherAlignClass)) { - autocompleteWrapper.removeClass(otherAlignClass); - } - } -} - -export default DocSearch; diff --git a/src/theme/SearchBar/algolia.css b/src/theme/SearchBar/algolia.css deleted file mode 100644 index 116243bff..000000000 --- a/src/theme/SearchBar/algolia.css +++ /dev/null @@ -1,553 +0,0 @@ -/* Bottom border of each suggestion */ -.algolia-docsearch-suggestion { - border-bottom-color: #3a3dd1; -} -/* Main category headers */ -.algolia-docsearch-suggestion--category-header { - background-color: #4b54de; -} -/* Highlighted search terms */ -.algolia-docsearch-suggestion--highlight { - color: #3a33d1; -} -/* Highligted search terms in the main category headers */ -.algolia-docsearch-suggestion--category-header - .algolia-docsearch-suggestion--highlight { - background-color: #4d47d5; -} -/* Currently selected suggestion */ -.aa-cursor .algolia-docsearch-suggestion--content { - color: #272296; -} -.aa-cursor .algolia-docsearch-suggestion { - background: #ebebfb; -} - -/* For bigger screens, when displaying results in two columns */ -@media (min-width: 768px) { - /* Bottom border of each suggestion */ - .algolia-docsearch-suggestion { - border-bottom-color: #7671df; - } - /* Left column, with secondary category header */ - .algolia-docsearch-suggestion--subcategory-column { - border-right-color: #7671df; - color: #4e4726; - } -} - -.searchbox { - display: inline-block; - position: relative; - width: 200px; - height: 32px !important; - white-space: nowrap; - box-sizing: border-box; - visibility: visible !important; -} - -.searchbox .algolia-autocomplete { - display: block; - width: 100%; - height: 100%; -} - -.searchbox__wrapper { - width: 100%; - height: 100%; - z-index: 999; - position: relative; -} - -.searchbox__input { - display: inline-block; - box-sizing: border-box; - -webkit-transition: box-shadow 0.4s ease, background 0.4s ease; - transition: box-shadow 0.4s ease, background 0.4s ease; - border: 0; - border-radius: 16px; - box-shadow: inset 0 0 0 1px #cccccc; - background: #ffffff !important; - padding: 0; - padding-right: 26px; - padding-left: 32px; - width: 100%; - height: 100%; - vertical-align: middle; - white-space: normal; - font-size: 12px; - -webkit-appearance: none; - -moz-appearance: none; - appearance: none; -} - -.searchbox__input::-webkit-search-decoration, -.searchbox__input::-webkit-search-cancel-button, -.searchbox__input::-webkit-search-results-button, -.searchbox__input::-webkit-search-results-decoration { - display: none; -} - -.searchbox__input:hover { - box-shadow: inset 0 0 0 1px #b3b3b3; -} - -.searchbox__input:focus, -.searchbox__input:active { - outline: 0; - box-shadow: inset 0 0 0 1px #aaaaaa; - background: #ffffff; -} - -.searchbox__input::-webkit-input-placeholder { - color: #aaaaaa; -} - -.searchbox__input::-moz-placeholder { - color: #aaaaaa; -} - -.searchbox__input:-ms-input-placeholder { - color: #aaaaaa; -} - -.searchbox__input::placeholder { - color: #aaaaaa; -} - -.searchbox__submit { - position: absolute; - top: 0; - margin: 0; - border: 0; - border-radius: 16px 0 0 16px; - background-color: rgba(69, 142, 225, 0); - padding: 0; - width: 32px; - height: 100%; - vertical-align: middle; - text-align: center; - font-size: inherit; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - right: inherit; - left: 0; -} - -.searchbox__submit::before { - display: inline-block; - margin-right: -4px; - height: 100%; - vertical-align: middle; - content: ''; -} - -.searchbox__submit:hover, -.searchbox__submit:active { - cursor: pointer; -} - -.searchbox__submit:focus { - outline: 0; -} - -.searchbox__submit svg { - width: 14px; - height: 14px; - vertical-align: middle; - fill: #6d7e96; -} - -.searchbox__reset { - display: block; - position: absolute; - top: 8px; - right: 8px; - margin: 0; - border: 0; - background: none; - cursor: pointer; - padding: 0; - font-size: inherit; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - fill: rgba(0, 0, 0, 0.5); -} - -.searchbox__reset.hide { - display: none; -} - -.searchbox__reset:focus { - outline: 0; -} - -.searchbox__reset svg { - display: block; - margin: 4px; - width: 8px; - height: 8px; -} - -.searchbox__input:valid ~ .searchbox__reset { - display: block; - -webkit-animation-name: sbx-reset-in; - animation-name: sbx-reset-in; - -webkit-animation-duration: 0.15s; - animation-duration: 0.15s; -} - -@-webkit-keyframes sbx-reset-in { - 0% { - -webkit-transform: translate3d(-20%, 0, 0); - transform: translate3d(-20%, 0, 0); - opacity: 0; - } - 100% { - -webkit-transform: none; - transform: none; - opacity: 1; - } -} - -@keyframes sbx-reset-in { - 0% { - -webkit-transform: translate3d(-20%, 0, 0); - transform: translate3d(-20%, 0, 0); - opacity: 0; - } - 100% { - -webkit-transform: none; - transform: none; - opacity: 1; - } -} - -.algolia-autocomplete .ds-dropdown-menu:before { - display: block; - position: absolute; - content: ''; - width: 14px; - height: 14px; - background: #373940; - z-index: 1000; - top: -7px; - border-top: 1px solid #373940; - border-right: 1px solid #373940; - -webkit-transform: rotate(-45deg); - transform: rotate(-45deg); - border-radius: 2px; -} - -.algolia-autocomplete .ds-dropdown-menu { - box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1); -} - -@media (min-width: 601px) { - .algolia-autocomplete.algolia-autocomplete-right .ds-dropdown-menu { - right: 0 !important; - left: inherit !important; - } - - .algolia-autocomplete.algolia-autocomplete-right .ds-dropdown-menu:before { - right: 48px; - } - - .algolia-autocomplete .ds-dropdown-menu { - position: relative; - top: -6px; - border-radius: 4px; - margin: 6px 0 0; - padding: 0; - text-align: left; - height: auto; - position: relative; - background: transparent; - border: none; - z-index: 999; - max-width: 600px; - min-width: 500px; - } -} - -@media (max-width: 600px) { - .algolia-autocomplete .ds-dropdown-menu { - z-index: 100; - position: fixed !important; - top: 50px !important; - left: auto !important; - right: 1rem !important; - width: 600px; - max-width: calc(100% - 2rem); - max-height: calc(100% - 5rem); - display: block; - } - - .algolia-autocomplete .ds-dropdown-menu:before { - right: 6rem; - } -} - -.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { - position: relative; - z-index: 1000; -} - -.algolia-autocomplete .ds-dropdown-menu .ds-suggestion { - cursor: pointer; -} - -.algolia-autocomplete .ds-dropdown-menu [class^='ds-dataset-'] { - position: relative; - border-radius: 4px; - overflow: auto; - padding: 0; - background: #ffffff; -} - -.algolia-autocomplete .ds-dropdown-menu * { - box-sizing: border-box; -} - -.algolia-autocomplete .algolia-docsearch-suggestion { - display: block; - position: relative; - padding: 0; - overflow: hidden; - text-decoration: none; -} - -.algolia-autocomplete .ds-cursor .algolia-docsearch-suggestion--wrapper { - background: #f1f1f1; - box-shadow: inset -2px 0 0 #61dafb; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--highlight { - background: #ffe564; - padding: 0.1em 0.05em; -} - -.algolia-autocomplete - .algolia-docsearch-suggestion--category-header - .algolia-docsearch-suggestion--category-header-lvl0 - .algolia-docsearch-suggestion--highlight, -.algolia-autocomplete - .algolia-docsearch-suggestion--category-header - .algolia-docsearch-suggestion--category-header-lvl1 - .algolia-docsearch-suggestion--highlight { - color: inherit; - background: inherit; -} - -.algolia-autocomplete - .algolia-docsearch-suggestion--text - .algolia-docsearch-suggestion--highlight { - padding: 0 0 1px; - background: inherit; - box-shadow: inset 0 -2px 0 0 rgba(69, 142, 225, 0.8); - color: inherit; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content { - display: block; - float: right; - width: 70%; - position: relative; - padding: 5.33333px 0 5.33333px 10.66667px; - cursor: pointer; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content:before { - content: ''; - position: absolute; - display: block; - top: 0; - height: 100%; - width: 1px; - background: #ececec; - left: -1px; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--category-header { - position: relative; - display: none; - font-size: 14px; - letter-spacing: 0.08em; - font-weight: 700; - background-color: #373940; - text-transform: uppercase; - color: #fff; - margin: 0; - padding: 5px 8px; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { - background-color: #fff; - width: 100%; - float: left; - padding: 8px 0 0 0; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { - float: left; - width: 30%; - display: none; - padding-left: 0; - text-align: right; - position: relative; - padding: 5.33333px 10.66667px; - color: #777; - font-size: 0.9em; - word-wrap: break-word; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column:before { - content: ''; - position: absolute; - display: block; - top: 0; - height: 100%; - width: 1px; - background: #ececec; - right: 0; -} - -.algolia-autocomplete - .algolia-docsearch-suggestion.algolia-docsearch-suggestion__main - .algolia-docsearch-suggestion--category-header, -.algolia-autocomplete - .algolia-docsearch-suggestion.algolia-docsearch-suggestion__secondary { - display: block; -} - -.algolia-autocomplete - .algolia-docsearch-suggestion--subcategory-column - .algolia-docsearch-suggestion--highlight { - background-color: inherit; - color: inherit; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-inline { - display: none; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--title { - margin-bottom: 4px; - color: #02060c; - font-size: 0.9em; - font-weight: bold; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--text { - display: block; - line-height: 1.2em; - font-size: 0.85em; - color: #63676d; - padding-right: 2px; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--version { - display: block; - font-size: 0.65em; - color: #a6aab1; - padding-top: 2px; - padding-right: 2px; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--no-results { - width: 100%; - padding: 8px 0; - text-align: center; - font-size: 1.2em; - background-color: #373940; - margin-top: -8px; -} - -.algolia-autocomplete - .algolia-docsearch-suggestion--no-results - .algolia-docsearch-suggestion--text { - color: #ffffff; - margin-top: 4px; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--no-results::before { - display: none; -} - -.algolia-autocomplete .algolia-docsearch-suggestion code { - padding: 1px 5px; - font-size: 90%; - border: none; - color: #222222; - background-color: #ebebeb; - border-radius: 3px; - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} - -.algolia-autocomplete - .algolia-docsearch-suggestion - code - .algolia-docsearch-suggestion--highlight { - background: none; -} - -.algolia-autocomplete - .algolia-docsearch-suggestion.algolia-docsearch-suggestion__main - .algolia-docsearch-suggestion--category-header { - color: white; - display: block; -} - -.algolia-autocomplete - .algolia-docsearch-suggestion.algolia-docsearch-suggestion__secondary - .algolia-docsearch-suggestion--subcategory-column { - display: block; -} - -.algolia-autocomplete .algolia-docsearch-footer { - background-color: #fff; - width: 100%; - height: 30px; - z-index: 2000; - float: right; - font-size: 0; - line-height: 0; -} - -.algolia-autocomplete .algolia-docsearch-footer--logo { - background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 130 18'%3E%3Cdefs%3E%3ClinearGradient id='a' x1='-36.87%25' x2='129.43%25' y1='134.94%25' y2='-27.7%25'%3E%3Cstop stop-color='%252300AEFF' offset='0%25'/%3E%3Cstop stop-color='%25233369E7' offset='100%25'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cpath fill='url(%2523a)' d='M59.4.02h13.3a2.37 2.37 0 0 1 2.38 2.37V15.6a2.37 2.37 0 0 1-2.38 2.36H59.4a2.37 2.37 0 0 1-2.38-2.36V2.38A2.37 2.37 0 0 1 59.4.02z'/%3E%3Cpath fill='%2523FFF' d='M66.26 4.56c-2.82 0-5.1 2.27-5.1 5.08 0 2.8 2.28 5.07 5.1 5.07 2.8 0 5.1-2.26 5.1-5.07 0-2.8-2.28-5.07-5.1-5.07zm0 8.65c-2 0-3.6-1.6-3.6-3.56 0-1.97 1.6-3.58 3.6-3.58 1.98 0 3.6 1.6 3.6 3.58a3.58 3.58 0 0 1-3.6 3.57zm0-6.4v2.66c0 .07.08.13.15.1l2.4-1.24c.04-.02.06-.1.03-.14a2.96 2.96 0 0 0-2.46-1.5c-.06 0-.1.05-.1.1zm-3.33-1.96l-.3-.3a.78.78 0 0 0-1.12 0l-.36.36a.77.77 0 0 0 0 1.1l.3.3c.05.05.13.04.17 0 .2-.25.4-.5.6-.7.23-.23.46-.43.7-.6.07-.04.07-.1.03-.16zm5-.8V3.4a.78.78 0 0 0-.78-.78h-1.83a.78.78 0 0 0-.78.78v.63c0 .07.06.12.14.1a5.74 5.74 0 0 1 1.58-.22c.52 0 1.04.07 1.54.2a.1.1 0 0 0 .13-.1z'/%3E%3Cpath fill='%2523182359' d='M102.16 13.76c0 1.46-.37 2.52-1.12 3.2-.75.67-1.9 1-3.44 1-.56 0-1.74-.1-2.67-.3l.34-1.7c.78.17 1.82.2 2.36.2.86 0 1.48-.16 1.84-.5.37-.36.55-.88.55-1.57v-.35a6.37 6.37 0 0 1-.84.3 4.15 4.15 0 0 1-1.2.17 4.5 4.5 0 0 1-1.6-.28 3.38 3.38 0 0 1-1.26-.82 3.74 3.74 0 0 1-.8-1.35c-.2-.54-.3-1.5-.3-2.2 0-.67.1-1.5.3-2.06a3.92 3.92 0 0 1 .9-1.43 4.12 4.12 0 0 1 1.45-.92 5.3 5.3 0 0 1 1.94-.37c.7 0 1.35.1 1.97.2a15.86 15.86 0 0 1 1.6.33v8.46zm-5.95-4.2c0 .9.2 1.88.6 2.3.4.4.9.62 1.53.62.34 0 .66-.05.96-.15a2.75 2.75 0 0 0 .73-.33V6.7a8.53 8.53 0 0 0-1.42-.17c-.76-.02-1.36.3-1.77.8-.4.5-.62 1.4-.62 2.23zm16.13 0c0 .72-.1 1.26-.32 1.85a4.4 4.4 0 0 1-.9 1.53c-.38.42-.85.75-1.4.98-.54.24-1.4.37-1.8.37-.43 0-1.27-.13-1.8-.36a4.1 4.1 0 0 1-1.4-.97 4.5 4.5 0 0 1-.92-1.52 5.04 5.04 0 0 1-.33-1.84c0-.72.1-1.4.32-2 .22-.6.53-1.1.92-1.5.4-.43.86-.75 1.4-.98a4.55 4.55 0 0 1 1.78-.34 4.7 4.7 0 0 1 1.8.34c.54.23 1 .55 1.4.97.38.42.68.92.9 1.5.23.6.35 1.3.35 2zm-2.2 0c0-.92-.2-1.7-.6-2.22-.38-.54-.94-.8-1.64-.8-.72 0-1.27.26-1.67.8-.4.54-.58 1.3-.58 2.22 0 .93.2 1.56.6 2.1.38.54.94.8 1.64.8s1.25-.26 1.65-.8c.4-.55.6-1.17.6-2.1zm6.97 4.7c-3.5.02-3.5-2.8-3.5-3.27L113.57.92l2.15-.34v10c0 .25 0 1.87 1.37 1.88v1.8zm3.77 0h-2.15v-9.2l2.15-.33v9.54zM119.8 3.74c.7 0 1.3-.58 1.3-1.3 0-.7-.58-1.3-1.3-1.3-.73 0-1.3.6-1.3 1.3 0 .72.58 1.3 1.3 1.3zm6.43 1c.7 0 1.3.1 1.78.27.5.18.88.42 1.17.73.28.3.5.74.6 1.18.13.46.2.95.2 1.5v5.47a25.24 25.24 0 0 1-1.5.25c-.67.1-1.42.15-2.25.15a6.83 6.83 0 0 1-1.52-.16 3.2 3.2 0 0 1-1.18-.5 2.46 2.46 0 0 1-.76-.9c-.18-.37-.27-.9-.27-1.44 0-.52.1-.85.3-1.2.2-.37.48-.67.83-.9a3.6 3.6 0 0 1 1.23-.5 7.07 7.07 0 0 1 2.2-.1l.83.16v-.35c0-.25-.03-.48-.1-.7a1.5 1.5 0 0 0-.3-.58c-.15-.18-.34-.3-.58-.4a2.54 2.54 0 0 0-.92-.17c-.5 0-.94.06-1.35.13-.4.08-.75.16-1 .25l-.27-1.74c.27-.1.67-.18 1.2-.28a9.34 9.34 0 0 1 1.65-.14zm.18 7.74c.66 0 1.15-.04 1.5-.1V10.2a5.1 5.1 0 0 0-2-.1c-.23.03-.45.1-.64.2a1.17 1.17 0 0 0-.47.38c-.13.17-.18.26-.18.52 0 .5.17.8.5.98.32.2.74.3 1.3.3zM84.1 4.8c.72 0 1.3.08 1.8.26.48.17.87.42 1.15.73.3.3.5.72.6 1.17.14.45.2.94.2 1.47v5.48a25.24 25.24 0 0 1-1.5.26c-.67.1-1.42.14-2.25.14a6.83 6.83 0 0 1-1.52-.16 3.2 3.2 0 0 1-1.18-.5 2.46 2.46 0 0 1-.76-.9c-.18-.38-.27-.9-.27-1.44 0-.53.1-.86.3-1.22.2-.36.5-.65.84-.88a3.6 3.6 0 0 1 1.24-.5 7.07 7.07 0 0 1 2.2-.1c.26.03.54.08.84.15v-.35c0-.24-.03-.48-.1-.7a1.5 1.5 0 0 0-.3-.58c-.15-.17-.34-.3-.58-.4a2.54 2.54 0 0 0-.9-.15c-.5 0-.96.05-1.37.12-.4.07-.75.15-1 .24l-.26-1.75c.27-.08.67-.17 1.18-.26a8.9 8.9 0 0 1 1.66-.15zm.2 7.73c.65 0 1.14-.04 1.48-.1v-2.17a5.1 5.1 0 0 0-1.98-.1c-.24.03-.46.1-.65.18a1.17 1.17 0 0 0-.47.4c-.12.17-.17.26-.17.52 0 .5.18.8.5.98.32.2.75.3 1.3.3zm8.68 1.74c-3.5 0-3.5-2.82-3.5-3.28L89.45.92 91.6.6v10c0 .25 0 1.87 1.38 1.88v1.8z'/%3E%3Cpath fill='%25231D3657' d='M5.03 11.03c0 .7-.26 1.24-.76 1.64-.5.4-1.2.6-2.1.6-.88 0-1.6-.14-2.17-.42v-1.2c.36.16.74.3 1.14.38.4.1.78.15 1.13.15.5 0 .88-.1 1.12-.3a.94.94 0 0 0 .35-.77.98.98 0 0 0-.33-.74c-.22-.2-.68-.44-1.37-.72-.72-.3-1.22-.62-1.52-1C.23 8.27.1 7.82.1 7.3c0-.65.22-1.17.7-1.55.46-.37 1.08-.56 1.86-.56.76 0 1.5.16 2.25.48l-.4 1.05c-.7-.3-1.32-.44-1.87-.44-.4 0-.73.08-.94.26a.9.9 0 0 0-.33.72c0 .2.04.38.12.52.08.15.22.3.42.4.2.14.55.3 1.06.52.58.24 1 .47 1.27.67.27.2.47.44.6.7.12.26.18.57.18.92zM9 13.27c-.92 0-1.64-.27-2.16-.8-.52-.55-.78-1.3-.78-2.24 0-.97.24-1.73.72-2.3.5-.54 1.15-.82 2-.82.78 0 1.4.25 1.85.72.46.48.7 1.14.7 1.97v.67H7.35c0 .58.17 1.02.46 1.33.3.3.7.47 1.24.47.36 0 .68-.04.98-.1a5.1 5.1 0 0 0 .98-.33v1.02a3.87 3.87 0 0 1-.94.32 5.72 5.72 0 0 1-1.08.1zm-.22-5.2c-.4 0-.73.12-.97.38s-.37.62-.42 1.1h2.7c0-.48-.13-.85-.36-1.1-.23-.26-.54-.38-.94-.38zm7.7 5.1l-.26-.84h-.05c-.28.36-.57.6-.86.74-.28.13-.65.2-1.1.2-.6 0-1.05-.16-1.38-.48-.32-.32-.5-.77-.5-1.34 0-.62.24-1.08.7-1.4.45-.3 1.14-.47 2.07-.5l1.02-.03V9.2c0-.37-.1-.65-.27-.84-.17-.2-.45-.28-.82-.28-.3 0-.6.04-.88.13a6.68 6.68 0 0 0-.8.33l-.4-.9a4.4 4.4 0 0 1 1.05-.4 4.86 4.86 0 0 1 1.08-.12c.76 0 1.33.18 1.7.5.4.33.6.85.6 1.56v4h-.9zm-1.9-.87c.47 0 .83-.13 1.1-.38.3-.26.43-.62.43-1.08v-.52l-.76.03c-.6.03-1.02.13-1.3.3s-.4.45-.4.82c0 .26.08.47.24.6.16.16.4.23.7.23zm7.57-5.2c.25 0 .46.03.62.06l-.12 1.18a2.38 2.38 0 0 0-.56-.06c-.5 0-.92.16-1.24.5-.3.32-.47.75-.47 1.27v3.1h-1.27V7.23h1l.16 1.05h.05c.2-.36.45-.64.77-.85a1.83 1.83 0 0 1 1.02-.3zm4.12 6.17c-.9 0-1.58-.27-2.05-.8-.47-.52-.7-1.27-.7-2.25 0-1 .24-1.77.73-2.3.5-.54 1.2-.8 2.12-.8.63 0 1.2.1 1.7.34l-.4 1c-.52-.2-.96-.3-1.3-.3-1.04 0-1.55.68-1.55 2.05 0 .67.13 1.17.38 1.5.26.34.64.5 1.13.5a3.23 3.23 0 0 0 1.6-.4v1.1a2.53 2.53 0 0 1-.73.28 4.36 4.36 0 0 1-.93.08zm8.28-.1h-1.27V9.5c0-.45-.1-.8-.28-1.02-.18-.23-.47-.34-.88-.34-.53 0-.9.16-1.16.48-.25.3-.38.85-.38 1.6v2.94h-1.26V4.8h1.26v2.12c0 .34-.02.7-.06 1.1h.08a1.76 1.76 0 0 1 .72-.67c.3-.16.66-.24 1.07-.24 1.43 0 2.15.74 2.15 2.2v3.86zM42.2 7.1c.74 0 1.32.28 1.73.82.4.53.62 1.3.62 2.26 0 .97-.2 1.73-.63 2.27-.42.54-1 .82-1.75.82s-1.33-.27-1.75-.8h-.08l-.23.7h-.94V4.8h1.26v2l-.02.64-.03.56h.05c.4-.6 1-.9 1.78-.9zm-.33 1.04c-.5 0-.88.15-1.1.45-.22.3-.34.8-.35 1.5v.08c0 .72.12 1.24.35 1.57.23.32.6.48 1.12.48.44 0 .78-.17 1-.53.24-.35.36-.87.36-1.53 0-1.35-.47-2.03-1.4-2.03zm3.24-.92h1.4l1.2 3.37c.18.47.3.92.36 1.34h.04l.18-.72 1.37-4H51l-2.53 6.73c-.46 1.23-1.23 1.85-2.3 1.85-.3 0-.56-.03-.83-.1v-1c.2.05.4.08.65.08.6 0 1.03-.36 1.28-1.06l.22-.56-2.4-5.94z'/%3E%3C/g%3E%3C/svg%3E"); - background-repeat: no-repeat; - background-position: center; - background-size: 100%; - overflow: hidden; - text-indent: -9000px; - width: 110px; - height: 100%; - display: block; - margin-left: auto; - margin-right: 5px; -} - -html[data-theme='dark'] .algolia-docsearch-suggestion--category-header, -html[data-theme='dark'] .algolia-docsearch-suggestion--wrapper, -html[data-theme='dark'] .algolia-docsearch-footer { - background: var(--ifm-background-color) !important; - color: var(--ifm-font-color-base) !important; -} - -html[data-theme='dark'] .algolia-docsearch-suggestion--title { - color: var(--ifm-font-color-base) !important; -} - -html[data-theme='dark'] .ds-cursor .algolia-docsearch-suggestion--wrapper { - background: var(--ifm-background-surface-color) !important; -} - -mark{ - background-color: lightblue; -} diff --git a/src/theme/SearchBar/index.jsx b/src/theme/SearchBar/index.jsx index c12b2cdca..b2b20375a 100644 --- a/src/theme/SearchBar/index.jsx +++ b/src/theme/SearchBar/index.jsx @@ -1,141 +1,590 @@ -import React, { useRef, useCallback, useState } from "react"; -import clsx from "clsx"; -import { useHistory } from "@docusaurus/router"; -import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; -import { usePluginData } from '@docusaurus/useGlobalData'; -import useIsBrowser from "@docusaurus/useIsBrowser"; -import { HighlightSearchResults } from "./HighlightSearchResults"; -const Search = props => { - const initialized = useRef(false); - const searchBarRef = useRef(null); - const [indexReady, setIndexReady] = useState(false); - const history = useHistory(); - const { siteConfig = {} } = useDocusaurusContext(); - const pluginConfig = (siteConfig.plugins || []).find(plugin => Array.isArray(plugin) && typeof plugin[0] === "string" && plugin[0].includes("docusaurus-lunr-search")) - const isBrowser = useIsBrowser(); - const { baseUrl } = siteConfig; - const assetUrl = pluginConfig && pluginConfig[1]?.assetUrl || baseUrl; - const initAlgolia = (searchDocs, searchIndex, DocSearch, options) => { - new DocSearch({ - searchDocs, - searchIndex, - baseUrl, - inputSelector: "#search_input_react", - // Override algolia's default selection event, allowing us to do client-side - // navigation and avoiding a full page refresh. - handleSelected: (_input, _event, suggestion) => { - const url = suggestion.url || "/"; - // Use an anchor tag to parse the absolute url into a relative url - // Alternatively, we can use new URL(suggestion.url) but its not supported in IE - const a = document.createElement("a"); - a.href = url; - _input.setVal(''); // clear value - _event.target.blur(); // remove focus - - // Get the highlight word from the suggestion. - let wordToHighlight = ''; - if (options.highlightResult) { - try { - const matchedLine = suggestion.text || suggestion.subcategory || suggestion.title; - const matchedWordResult = matchedLine.match(new RegExp('\\w*', 'g')); - if (matchedWordResult && matchedWordResult.length > 0) { - const tempDoc = document.createElement('div'); - tempDoc.innerHTML = matchedWordResult[0]; - wordToHighlight = tempDoc.textContent; - } - } catch (e) { - console.log(e); - } - } +import React, { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; +import clsx from 'clsx'; +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; +import {translate} from '@docusaurus/Translate'; +import './styles.css'; - history.push(url, { - highlightState: { wordToHighlight }, +const MIN_QUERY_LENGTH = 3; +const TAB_ORDER = ['game', 'docs', 'landingPage', 'posts']; +const sanitizeBase = (url) => url.replace(/\/+$/, ''); + +const buildTabs = (counts, labels) => { + const entries = []; + const types = counts?.types || {}; + TAB_ORDER.forEach((key) => { + if (typeof labels[key] !== 'string') { + return; + } + const count = types[key] ?? 0; + entries.push({ + key, + count, + label: labels[key], }); - }, - maxHits: options.maxHits }); - }; - - const pluginData = usePluginData('docusaurus-lunr-search'); - const getSearchDoc = () => - process.env.NODE_ENV === "production" - ? fetch(`${assetUrl}${pluginData.fileNames.searchDoc}`).then((content) => content.json()) - : Promise.resolve({}); - - const getLunrIndex = () => - process.env.NODE_ENV === "production" - ? fetch(`${assetUrl}${pluginData.fileNames.lunrIndex}`).then((content) => content.json()) - : Promise.resolve([]); - - const loadAlgolia = () => { - if (!initialized.current) { - Promise.all([ - getSearchDoc(), - getLunrIndex(), - import("./DocSearch"), - import("./algolia.css") - ]).then(([searchDocFile, searchIndex, { default: DocSearch }]) => { - const { searchDocs, options } = searchDocFile; - if (!searchDocs || searchDocs.length === 0) { - return; - } - initAlgolia(searchDocs, searchIndex, DocSearch, options); - setIndexReady(true); - }); - initialized.current = true; + + return entries.filter((tab) => tab.count > 0); +}; + +const normalizeItems = (items) => { + if (Array.isArray(items)) { + return items; + } + + return []; +}; + +const renderIcon = (icon, title) => { + if (! icon || typeof icon !== 'object') { + return null; + } + + if (icon.type === 'image') { + return ; + } + + if (icon.type === 'html') { + return ( + + ); + } + + if (icon.type === 'class') { + return ; } - }; - - const toggleSearchIconClick = useCallback( - e => { - if (!searchBarRef.current.contains(e.target)) { - searchBarRef.current.focus(); - } - - props.handleSearchBarToggle && props.handleSearchBarToggle(!props.isSearchBarExpanded); - }, - [props.isSearchBarExpanded] - ); - - let placeholder - if (isBrowser) { - loadAlgolia(); - placeholder = window.navigator.platform.startsWith("Mac") ? - 'Search ⌘+K' : 'Search Ctrl+K' - } - - return ( - - - - - - ); + + return null; +}; + +const Search = (props) => { + const containerRef = useRef(null); + const requestId = useRef(0); + const debounceRef = useRef(null); + const abortRef = useRef(null); + const aiRequestRef = useRef(0); + + const {siteConfig, i18n} = useDocusaurusContext(); + const locale = i18n?.currentLocale || 'en'; + const copy = useMemo(() => ({ + placeholder: translate({ + id: 'search.placeholder', + message: 'Search products, games, docs…', + description: 'Placeholder text for the navbar search input', + }), + loading: translate({ + id: 'search.loading', + message: 'Searching…', + description: 'Loading text while search results are being fetched', + }), + empty: translate({ + id: 'search.empty', + message: 'No matching results.', + description: 'Shown when search returns no results', + }), + failure: translate({ + id: 'search.failure', + message: 'Search is unavailable. Please try again.', + description: 'Shown when search fails', + }), + short: translate({ + id: 'search.short', + message: 'Enter at least 3 characters.', + description: 'Shown when the search query is too short', + }), + askAiHeading: translate({ + id: 'search.askAiHeading', + message: 'Ask our AI', + description: 'Heading for the Ask AI section', + }), + askAiDescription: translate({ + id: 'search.askAiDescription', + message: 'Get AI-powered answers based on our documentation.', + description: 'Description for the Ask AI section', + }), + askAiButton: translate({ + id: 'search.askAiButton', + message: 'Go!', + description: 'Button label for the Ask AI action', + }), + askAiGenericError: translate({ + id: 'search.askAiGenericError', + message: 'Failed to generate answer. Please try again.', + description: 'Generic error for Ask AI failures', + }), + askAiUnavailable: translate({ + id: 'search.askAiUnavailable', + message: 'Ask AI is currently unavailable.', + description: 'Shown when Ask AI is disabled', + }), + askAiRateLimited: translate({ + id: 'search.askAiRateLimited', + message: 'Slow down, you\'re asking too many questions, please try again later!', + description: 'Shown when Ask AI rate limit is reached', + }), + askAiLoadingText: translate({ + id: 'search.askAiLoadingText', + message: 'Thinking...', + description: 'Loading text while Ask AI prepares an answer', + }), + tabs: { + game: translate({ + id: 'search.tabs.game', + message: 'Products', + description: 'Tab label for product search results', + }), + docs: translate({ + id: 'search.tabs.docs', + message: 'Docs', + description: 'Tab label for documentation search results', + }), + landingPage: translate({ + id: 'search.tabs.landingPage', + message: 'Pages', + description: 'Tab label for landing page search results', + }), + posts: translate({ + id: 'search.tabs.posts', + message: 'Blog', + description: 'Tab label for blog search results', + }), + }, + }), [locale]); + const marketingBase = useMemo(() => { + const source = siteConfig?.customFields?.searchSite || siteConfig?.url || ''; + + return sanitizeBase(String(source)); + }, [siteConfig]); + + const [query, setQuery] = useState(''); + const [open, setOpen] = useState(false); + const [activeTab, setActiveTab] = useState('game'); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [results, setResults] = useState(null); + const [askAiEnabled, setAskAiEnabled] = useState(false); + const [aiLoading, setAiLoading] = useState(false); + const [aiAnswer, setAiAnswer] = useState(null); + const [aiError, setAiError] = useState(null); + const [currentLoadingLabel, setCurrentLoadingLabel] = useState(copy.loading); + const expanded = open || props.isSearchBarExpanded; + const hasQuery = query.trim().length >= MIN_QUERY_LENGTH; + const hasResults = results?.counts?.global > 0; + const showAskAi = askAiEnabled && hasQuery && hasResults; + const canRequestAi = showAskAi && ! aiLoading; + + const buildSearchUrl = useCallback((term, echoId) => { + const endpoint = `${marketingBase}/${locale}/customer/_ajax/json_getWebSearchResults.php`; + const url = new URL(endpoint); + url.searchParams.set('searchTerm', term); + url.searchParams.set('show', String(echoId)); + url.searchParams.set('language', locale); + + return url.toString(); + }, [locale, marketingBase]); + + const fetchResults = useCallback(async (term, echoId) => { + setError(null); + if (abortRef.current) { + abortRef.current.abort(); + } + const controller = new AbortController(); + abortRef.current = controller; + + const response = await fetch(buildSearchUrl(term, echoId), { + method: 'GET', + headers: { + 'X-Requested-With': 'XMLHttpRequest', + }, + signal: controller.signal, + }).catch((error) => { + if (error?.name === 'AbortError') { + return null; + } + + return null; + }); + + if (abortRef.current === controller) { + abortRef.current = null; + } + + if (requestId.current !== echoId) { + return; + } + + if (! response || ! response.ok) { + setError(copy.failure); + setLoading(false); + + return; + } + + let payload = null; + + try { + payload = await response.json(); + } catch (exception) { + payload = null; + } + + if (! payload || payload.result !== 'success') { + setError(copy.failure); + setLoading(false); + + return; + } + + const counts = payload.data?.counts || {global: 0, types: {}}; + const items = payload.data?.results || {}; + setResults({counts, items}); + const availableTabs = buildTabs(counts, copy.tabs); + + if (availableTabs.length > 0) { + setActiveTab(availableTabs[0].key); + } + + setLoading(false); + }, [buildSearchUrl, copy.failure, copy.tabs]); + + const resetAiState = useCallback(() => { + setAiAnswer(null); + setAiError(null); + setAiLoading(false); + }, []); + + const resolveAiError = useCallback((message) => { + const lookup = { + ask_ai_disabled: copy.askAiUnavailable, + ask_ai_rate_limited: copy.askAiRateLimited, + ask_ai_invalid_query: copy.askAiGenericError, + ask_ai_no_results: copy.empty, + }; + + return lookup[message] ?? copy.askAiGenericError; + }, [copy.askAiGenericError, copy.askAiRateLimited, copy.askAiUnavailable, copy.empty]); + + const fetchAskAiConfig = useCallback(async () => { + const url = new URL(`${marketingBase}/${locale}/customer/_ajax/json_getAISearchAnswer.php`); + url.searchParams.set('action', 'config'); + url.searchParams.set('language', locale); + + const response = await fetch(url.toString(), { + method: 'GET', + headers: { + 'X-Requested-With': 'XMLHttpRequest', + }, + }).catch(() => null); + + if (! response) { + setAskAiEnabled(false); + return; + } + + let payload = null; + try { + payload = await response.json(); + } catch (exception) { + payload = null; + } + + if (! payload || payload.result !== 'success') { + setAskAiEnabled(false); + resetAiState(); + return; + } + + const enabled = Boolean(payload.data?.enabled); + setAskAiEnabled(enabled); + if (! enabled) { + resetAiState(); + } + }, [locale, marketingBase, resetAiState]); + + const requestAiAnswer = useCallback(async () => { + if (! canRequestAi) { + return; + } + + setAiError(null); + setAiAnswer(null); + setAiLoading(true); + setCurrentLoadingLabel(copy.askAiLoadingText); + + const reqId = aiRequestRef.current + 1; + aiRequestRef.current = reqId; + + const url = new URL(`${marketingBase}/${locale}/customer/_ajax/json_getAISearchAnswer.php`); + url.searchParams.set('searchTerm', query.trim()); + url.searchParams.set('language', locale); + + const response = await fetch(url.toString(), { + method: 'GET', + headers: { + 'X-Requested-With': 'XMLHttpRequest', + }, + }).catch(() => null); + + if (reqId !== aiRequestRef.current) { + return; + } + + if (! response) { + setAiError(copy.failure); + setAiLoading(false); + return; + } + + let payload = null; + try { + payload = await response.json(); + } catch (exception) { + payload = null; + } + + if (! payload || payload.result !== 'success') { + setAiError(resolveAiError(payload?.message)); + setAiLoading(false); + return; + } + + setAiAnswer(payload.data?.answer ?? ''); + setAiLoading(false); + }, [canRequestAi, copy.askAiLoadingText, copy.failure, locale, marketingBase, query, resolveAiError]); + + useEffect(() => { + if (debounceRef.current) { + clearTimeout(debounceRef.current); + } + + if (query.trim().length < MIN_QUERY_LENGTH) { + setLoading(false); + setResults(null); + resetAiState(); + + return undefined; + } + + setLoading(true); + const echoId = requestId.current + 1; + requestId.current = echoId; + debounceRef.current = window.setTimeout(() => { + fetchResults(query.trim(), echoId); + }, 300); + + return () => { + if (debounceRef.current) { + clearTimeout(debounceRef.current); + } + }; + }, [fetchResults, query, resetAiState]); + + useEffect(() => { + const handler = (event) => { + if (! containerRef.current) { + return; + } + + if (! containerRef.current.contains(event.target)) { + setOpen(false); + props.handleSearchBarToggle?.(false); + } + }; + + document.addEventListener('mousedown', handler); + + return () => { + document.removeEventListener('mousedown', handler); + }; + }, [props]); + + useEffect(() => { + fetchAskAiConfig(); + }, [fetchAskAiConfig]); + + useEffect(() => { + setCurrentLoadingLabel(copy.loading); + }, [copy.loading]); + + useEffect(() => { + if (results === null) { + resetAiState(); + } + }, [results, resetAiState]); + + const tabs = useMemo(() => { + if (! results) { + return []; + } + + return buildTabs(results.counts, copy.tabs); + }, [copy.tabs, results]); + + const activeItems = useMemo(() => { + if (! results) { + return []; + } + + const bucket = results.items?.[activeTab]; + + return normalizeItems(bucket); + }, [activeTab, results]); + + const showPanel = open || query.trim().length >= MIN_QUERY_LENGTH; + + return ( + + + 🔍 + { + setQuery(event.target.value); + setOpen(true); + props.handleSearchBarToggle?.(true); + }} + onFocus={() => { + setOpen(true); + props.handleSearchBarToggle?.(true); + }} + placeholder={copy.placeholder} + aria-label={copy.placeholder} + className={clsx( + 'navbar__search-input', + expanded ? 'search-bar-expanded' : 'search-bar', + )} + autoComplete="off" + /> + {query !== '' && ( + { + setQuery(''); + setResults(null); + setOpen(false); + setLoading(false); + setError(null); + props.handleSearchBarToggle?.(false); + }} + aria-label="Clear search" + > + × + + )} + + + {showPanel && ( + + {query.trim().length < MIN_QUERY_LENGTH && ( + {copy.short} + )} + + {query.trim().length >= MIN_QUERY_LENGTH && loading && ( + {copy.loading} + )} + + {query.trim().length >= MIN_QUERY_LENGTH && ! loading && error && ( + {error} + )} + + {query.trim().length >= MIN_QUERY_LENGTH && ! loading && ! error && ! hasResults && ( + {copy.empty} + )} + + {query.trim().length >= MIN_QUERY_LENGTH && ! loading && ! error && hasResults && ( + <> + {showAskAi && ( + + + + {copy.askAiHeading} + {copy.askAiDescription} + + + {aiLoading && ( + + )} + {copy.askAiButton} + + + {aiLoading && ( + + + {currentLoadingLabel} + + )} + {! aiLoading && aiAnswer && ( + + )} + {! aiLoading && aiError && ( + {aiError} + )} + + )} + + + {tabs.map((tab) => ( + setActiveTab(tab.key)} + > + {tab.label} + {tab.count} + + ))} + + + + {activeItems.map((item) => ( + + + {renderIcon(item.icon, item.title)} + + + + {item.cheapestPrice && ( + {item.cheapestPrice} + )} + + + ))} + + > + )} + + )} + + ); }; export default Search; diff --git a/src/theme/SearchBar/lunar-search.js b/src/theme/SearchBar/lunar-search.js deleted file mode 100644 index cac06c40d..000000000 --- a/src/theme/SearchBar/lunar-search.js +++ /dev/null @@ -1,149 +0,0 @@ -import lunr from "@generated/lunr.client"; -lunr.tokenizer.separator = /[\s\-/]+/; - -class LunrSearchAdapter { - constructor(searchDocs, searchIndex, baseUrl = '/', maxHits) { - this.searchDocs = searchDocs; - this.lunrIndex = lunr.Index.load(searchIndex); - this.baseUrl = baseUrl; - this.maxHits = maxHits; - } - - getLunrResult(input) { - return this.lunrIndex.query(function (query) { - const tokens = lunr.tokenizer(input); - query.term(tokens, { - boost: 10 - }); - query.term(tokens, { - wildcard: lunr.Query.wildcard.TRAILING - }); - }); - } - - getHit(doc, formattedTitle, formattedContent) { - return { - hierarchy: { - lvl0: doc.pageTitle || doc.title, - lvl1: doc.type === 0 ? null : doc.title - }, - url: doc.url, - version: doc.version, - _snippetResult: formattedContent ? { - content: { - value: formattedContent, - matchLevel: "full" - } - } : null, - _highlightResult: { - hierarchy: { - lvl0: { - value: doc.type === 0 ? formattedTitle || doc.title : doc.pageTitle, - }, - lvl1: - doc.type === 0 - ? null - : { - value: formattedTitle || doc.title - } - } - } - }; - } - getTitleHit(doc, position, length) { - const start = position[0]; - const end = position[0] + length; - let formattedTitle = doc.title.substring(0, start) + '' + doc.title.substring(start, end) + '' + doc.title.substring(end, doc.title.length); - return this.getHit(doc, formattedTitle) - } - - getKeywordHit(doc, position, length) { - const start = position[0]; - const end = position[0] + length; - let formattedTitle = doc.title + 'Keywords: ' + doc.keywords.substring(0, start) + '' + doc.keywords.substring(start, end) + '' + doc.keywords.substring(end, doc.keywords.length) + '' - return this.getHit(doc, formattedTitle) - } - - getContentHit(doc, position) { - const start = position[0]; - const end = position[0] + position[1]; - let previewStart = start; - let previewEnd = end; - let ellipsesBefore = true; - let ellipsesAfter = true; - for (let k = 0; k < 3; k++) { - const nextSpace = doc.content.lastIndexOf(' ', previewStart - 2); - const nextDot = doc.content.lastIndexOf('.', previewStart - 2); - if ((nextDot > 0) && (nextDot > nextSpace)) { - previewStart = nextDot + 1; - ellipsesBefore = false; - break; - } - if (nextSpace < 0) { - previewStart = 0; - ellipsesBefore = false; - break; - } - previewStart = nextSpace + 1; - } - for (let k = 0; k < 10; k++) { - const nextSpace = doc.content.indexOf(' ', previewEnd + 1); - const nextDot = doc.content.indexOf('.', previewEnd + 1); - if ((nextDot > 0) && (nextDot < nextSpace)) { - previewEnd = nextDot; - ellipsesAfter = false; - break; - } - if (nextSpace < 0) { - previewEnd = doc.content.length; - ellipsesAfter = false; - break; - } - previewEnd = nextSpace; - } - let preview = doc.content.substring(previewStart, start); - if (ellipsesBefore) { - preview = '... ' + preview; - } - preview += '' + doc.content.substring(start, end) + ''; - preview += doc.content.substring(end, previewEnd); - if (ellipsesAfter) { - preview += ' ...'; - } - return this.getHit(doc, null, preview); - - } - search(input) { - return new Promise((resolve, rej) => { - const results = this.getLunrResult(input); - const hits = []; - results.length > this.maxHits && (results.length = this.maxHits); - this.titleHitsRes = [] - this.contentHitsRes = [] - results.forEach(result => { - const doc = this.searchDocs[result.ref]; - const { metadata } = result.matchData; - for (let i in metadata) { - if (metadata[i].title) { - if (!this.titleHitsRes.includes(result.ref)) { - const position = metadata[i].title.position[0] - hits.push(this.getTitleHit(doc, position, input.length)); - this.titleHitsRes.push(result.ref); - } - } else if (metadata[i].content) { - const position = metadata[i].content.position[0] - hits.push(this.getContentHit(doc, position)) - } else if (metadata[i].keywords) { - const position = metadata[i].keywords.position[0] - hits.push(this.getKeywordHit(doc, position, input.length)); - this.titleHitsRes.push(result.ref); - } - } - }); - hits.length > this.maxHits && (hits.length = this.maxHits); - resolve(hits); - }); - } -} - -export default LunrSearchAdapter; diff --git a/src/theme/SearchBar/styles.css b/src/theme/SearchBar/styles.css index 8dc3b0a12..bd2bad286 100644 --- a/src/theme/SearchBar/styles.css +++ b/src/theme/SearchBar/styles.css @@ -1,33 +1,376 @@ -.search-icon { - background-image: var(--ifm-navbar-search-input-icon); - height: auto; - width: 24px; +:root { + --zap-search-surface: #f8fafc; + --zap-search-surface-strong: #eef2ff; + --zap-search-border: rgba(15, 23, 42, 0.08); + --zap-search-border-strong: rgba(99, 102, 241, 0.25); + --zap-search-text: #0f172a; + --zap-search-text-muted: #475569; + --zap-search-accent: #a3e635; + --zap-search-accent-strong: #65a30d; + --zap-search-shadow: 0 20px 60px rgba(15, 23, 42, 0.18); +} + +[data-theme='dark'] { + --zap-search-surface: rgba(15, 23, 42, 0.92); + --zap-search-surface-strong: rgba(34, 197, 94, 0.08); + --zap-search-border: rgba(148, 163, 184, 0.25); + --zap-search-border-strong: rgba(132, 204, 22, 0.4); + --zap-search-text: #e2e8f0; + --zap-search-text-muted: #94a3b8; + --zap-search-accent: #bef264; + --zap-search-accent-strong: #4ade80; + --zap-search-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); +} + +.zap-search { + position: relative; + max-width: 560px; +} + +.zap-search-input-wrap { + position: relative; + display: flex; + align-items: center; +} + +.zap-search-icon-left { + position: absolute; + left: 12px; + font-size: 14px; + opacity: 0.7; +} + +.zap-search-clear { + position: absolute; + right: 10px; + background: transparent; + border: none; + cursor: pointer; + color: var(--zap-search-text-muted); + font-size: 16px; + line-height: 1; +} + +.zap-search-clear:hover { + color: var(--zap-search-accent-strong); +} + +.zap-search .navbar__search-input { + padding-left: 32px; + padding-right: 32px; + background: var(--zap-search-surface); + border-radius: 12px; + border: 1px solid var(--zap-search-border); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), var(--zap-search-shadow); + color: var(--zap-search-text); +} + +.zap-search .navbar__search-input:focus { + border-color: var(--zap-search-border-strong); + box-shadow: 0 0 0 3px var(--zap-search-surface-strong), var(--zap-search-shadow); +} + +.zap-search-panel { + position: absolute; + right: 0; + top: calc(100% + 10px); + width: min(560px, 92vw); + background: var(--zap-search-surface); + border: 1px solid var(--zap-search-border); + border-radius: 14px; + box-shadow: var(--zap-search-shadow); + z-index: 20; + padding: 14px; + backdrop-filter: blur(10px); +} + +.zap-search-status { + padding: 12px; + border-radius: 10px; + background: var(--zap-search-surface-strong); + color: var(--zap-search-text); + font-size: 14px; +} + +.zap-search-error { + background: rgba(239, 68, 68, 0.12); + color: #ef4444; +} + +.zap-search-tabs { + display: flex; + gap: 14px; + padding: 0 2px 10px; + margin-bottom: 12px; + border-bottom: 1px solid var(--zap-search-border); + overflow-x: auto; + overflow-y: visible; +} + +.zap-search-tab { + position: relative; + display: inline-flex; + align-items: center; + gap: 8px; + padding: 6px 0; + border: none; + border-radius: 0; + background: transparent; + color: var(--zap-search-text-muted); cursor: pointer; - padding: 8px; - line-height: 32px; - background-repeat: no-repeat; - background-position: center; - display: none; + font-size: 14px; + font-weight: 600; + transition: all 180ms ease; +} + +.zap-search-tab:hover { + color: var(--zap-search-text); +} + +.zap-search-tab-active { + color: var(--zap-search-text); +} + +.zap-search-tab::after { + content: ''; + position: absolute; + left: 0; + right: 0; + bottom: -11px; + height: 3px; + border-radius: 999px; + background: transparent; + box-shadow: 0 0 0 rgba(52, 211, 153, 0); + opacity: 0; + transition: all 180ms ease; +} + +.zap-search-tab-active::after { + background: linear-gradient(90deg, var(--zap-search-accent-strong), var(--zap-search-accent)); + box-shadow: 0 0 18px rgba(52, 211, 153, 0.55); + opacity: 1; } -.search-icon-hidden { - visibility: hidden; +.zap-search-badge { + display: inline-flex; + min-width: 22px; + height: 22px; + padding: 0 6px; + align-items: center; + justify-content: center; + border-radius: 999px; + background: rgba(0, 0, 0, 0.06); + color: inherit; + font-weight: 600; + font-size: 12px; } -@media (max-width: 360px) { - .search-bar { - width: 0 !important; - background: none !important; - padding: 0 !important; - transition: none !important; +.zap-search-tab-active .zap-search-badge { + background: rgba(0, 0, 0, 0.08); +} + +[data-theme='dark'] .zap-search-tab-active .zap-search-badge { + background: rgba(255, 255, 255, 0.16); +} + +.zap-search-list { + display: flex; + flex-direction: column; + gap: 10px; + max-height: 360px; + overflow-y: auto; +} + +.zap-search-item { + display: flex; + gap: 14px; + align-items: center; + padding: 12px; + border-radius: 12px; + text-decoration: none; + color: var(--zap-search-text); + border: 1px solid transparent; + transition: all 160ms ease; +} + +.zap-search-item:hover { + background: var(--zap-search-surface-strong); + border-color: var(--zap-search-border-strong); + box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12); +} + +[data-theme='dark'] .zap-search-item:hover { + box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25); +} + +.zap-search-item-icon { + width: 46px; + height: 46px; + border-radius: 12px; + display: inline-flex; + align-items: center; + justify-content: center; + background: var(--zap-search-surface-strong); + border: 1px solid var(--zap-search-border); + color: var(--zap-search-text); +} + +.zap-search-icon { + width: 28px; + height: 28px; + display: inline-flex; + align-items: center; + justify-content: center; +} + +.zap-search-icon svg { + width: 100%; + height: 100%; + display: block; + color: inherit; + stroke: currentColor; + fill: none; +} + +.zap-search-item-body { + display: flex; + flex-direction: column; + gap: 4px; +} + +.zap-search-item-title { + font-weight: 700; + font-size: 15px; + line-height: 1.35; + color: var(--zap-search-text); +} + +.zap-search-item-meta { + font-size: 13px; + color: var(--zap-search-text-muted); +} + +.zap-search-ai { + margin-bottom: 12px; + padding: 14px; + border-radius: 12px; + border: 1px solid var(--zap-search-border); + background: var(--zap-search-surface-strong); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04); +} + +.zap-search-ai__header { + display: flex; + flex-direction: column; + gap: 8px; +} + +@media (min-width: 640px) { + .zap-search-ai__header { + flex-direction: row; + align-items: center; + justify-content: space-between; } +} - .search-bar-expanded { - width: 9rem !important; +.zap-search-ai__title { + font-weight: 700; + color: var(--zap-search-text); + font-size: 15px; +} + +.zap-search-ai__desc { + color: var(--zap-search-text-muted); + font-size: 13px; +} + +.zap-search-ai__button { + display: inline-flex; + align-items: center; + gap: 8px; + padding: 9px 12px; + border-radius: 10px; + border: 1px solid rgba(132, 204, 22, 0.5); + background: linear-gradient(180deg, rgba(190, 242, 100, 0.2), rgba(52, 211, 153, 0.2)); + color: #0f172a; + font-weight: 700; + font-size: 12px; + text-transform: uppercase; + letter-spacing: 0.04em; + cursor: pointer; + transition: all 160ms ease; +} + +[data-theme='dark'] .zap-search-ai__button { + color: #f8fafc; +} + +.zap-search-ai__button:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +.zap-search-ai__button:not(:disabled):hover { + border-color: rgba(132, 204, 22, 0.8); + box-shadow: 0 10px 24px rgba(34, 197, 94, 0.2); +} + +.zap-search-ai__spinner { + width: 16px; + height: 16px; + border-radius: 999px; + border: 2px solid rgba(15, 23, 42, 0.18); + border-top-color: var(--zap-search-accent-strong); + animation: zap-spin 0.9s linear infinite; +} + +[data-theme='dark'] .zap-search-ai__spinner { + border: 2px solid rgba(226, 232, 240, 0.2); +} + +.zap-search-ai__status { + display: flex; + align-items: center; + gap: 10px; + margin-top: 12px; + color: var(--zap-search-text); + font-size: 13px; +} + +.zap-search-ai__answer { + margin-top: 12px; + color: var(--zap-search-text); + font-size: 14px; + line-height: 1.6; +} + +.zap-search-ai__answer a { + color: var(--zap-search-accent-strong); +} + +.zap-search-ai__error { + margin-top: 12px; + padding: 10px; + border-radius: 10px; + border: 1px solid rgba(248, 113, 113, 0.4); + background: rgba(248, 113, 113, 0.1); + color: #ef4444; + font-size: 13px; +} + +@media (max-width: 480px) { + .zap-search-panel { + left: 0; + right: 0; + width: auto; } +} - .search-icon { - display: inline; - vertical-align: sub; +@keyframes zap-spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); } } diff --git a/src/theme/SearchBar/templates.js b/src/theme/SearchBar/templates.js deleted file mode 100644 index 354a98f82..000000000 --- a/src/theme/SearchBar/templates.js +++ /dev/null @@ -1,113 +0,0 @@ -const prefix = 'algolia-docsearch'; -const suggestionPrefix = `${prefix}-suggestion`; -const footerPrefix = `${prefix}-footer`; - -const templates = { - suggestion: ` - - - {{{category}}} - - - - {{{subcategory}}} - - {{#isTextOrSubcategoryNonEmpty}} - - {{{subcategory}}} - {{{title}}} - {{#text}}{{{text}}}{{/text}} - {{#version}}{{version}}{{/version}} - - {{/isTextOrSubcategoryNonEmpty}} - - - `, - suggestionSimple: ` - - - {{^isLvl0}} - {{{category}}} - {{^isLvl1}} - {{^isLvl1EmptyOrDuplicate}} - - {{{subcategory}}} - - {{/isLvl1EmptyOrDuplicate}} - {{/isLvl1}} - {{/isLvl0}} - - {{#isLvl2}} - {{{title}}} - {{/isLvl2}} - {{#isLvl1}} - {{{subcategory}}} - {{/isLvl1}} - {{#isLvl0}} - {{{category}}} - {{/isLvl0}} - - - - {{#text}} - - {{{text}}} - - {{/text}} - - - `, - footer: ` - - `, - empty: ` - - - - - - No results found for query "{{query}}" - - - - - - `, - searchBox: ` - - - - - - - - - - - - - - - - - - - - - - - `, -}; - -export default templates; diff --git a/src/theme/SearchBar/utils.js b/src/theme/SearchBar/utils.js deleted file mode 100644 index 0807500d7..000000000 --- a/src/theme/SearchBar/utils.js +++ /dev/null @@ -1,270 +0,0 @@ -import $ from "autocomplete.js/zepto"; - -const utils = { - /* - * Move the content of an object key one level higher. - * eg. - * { - * name: 'My name', - * hierarchy: { - * lvl0: 'Foo', - * lvl1: 'Bar' - * } - * } - * Will be converted to - * { - * name: 'My name', - * lvl0: 'Foo', - * lvl1: 'Bar' - * } - * @param {Object} object Main object - * @param {String} property Main object key to move up - * @return {Object} - * @throws Error when key is not an attribute of Object or is not an object itself - */ - mergeKeyWithParent(object, property) { - if (object[property] === undefined) { - return object; - } - if (typeof object[property] !== 'object') { - return object; - } - const newObject = $.extend({}, object, object[property]); - delete newObject[property]; - return newObject; - }, - /* - * Group all objects of a collection by the value of the specified attribute - * If the attribute is a string, use the lowercase form. - * - * eg. - * groupBy([ - * {name: 'Tim', category: 'dev'}, - * {name: 'Vincent', category: 'dev'}, - * {name: 'Ben', category: 'sales'}, - * {name: 'Jeremy', category: 'sales'}, - * {name: 'AlexS', category: 'dev'}, - * {name: 'AlexK', category: 'sales'} - * ], 'category'); - * => - * { - * 'devs': [ - * {name: 'Tim', category: 'dev'}, - * {name: 'Vincent', category: 'dev'}, - * {name: 'AlexS', category: 'dev'} - * ], - * 'sales': [ - * {name: 'Ben', category: 'sales'}, - * {name: 'Jeremy', category: 'sales'}, - * {name: 'AlexK', category: 'sales'} - * ] - * } - * @param {array} collection Array of objects to group - * @param {String} property The attribute on which apply the grouping - * @return {array} - * @throws Error when one of the element does not have the specified property - */ - groupBy(collection, property) { - const newCollection = {}; - $.each(collection, (index, item) => { - if (item[property] === undefined) { - throw new Error(`[groupBy]: Object has no key ${property}`); - } - let key = item[property]; - if (typeof key === 'string') { - key = key.toLowerCase(); - } - // fix #171 the given data type of docsearch hits might be conflict with the properties of the native Object, - // such as the constructor, so we need to do this check. - if (!Object.prototype.hasOwnProperty.call(newCollection, key)) { - newCollection[key] = []; - } - newCollection[key].push(item); - }); - return newCollection; - }, - /* - * Return an array of all the values of the specified object - * eg. - * values({ - * foo: 42, - * bar: true, - * baz: 'yep' - * }) - * => - * [42, true, yep] - * @param {object} object Object to extract values from - * @return {array} - */ - values(object) { - return Object.keys(object).map(key => object[key]); - }, - /* - * Flattens an array - * eg. - * flatten([1, 2, [3, 4], [5, 6]]) - * => - * [1, 2, 3, 4, 5, 6] - * @param {array} array Array to flatten - * @return {array} - */ - flatten(array) { - const results = []; - array.forEach(value => { - if (!Array.isArray(value)) { - results.push(value); - return; - } - value.forEach(subvalue => { - results.push(subvalue); - }); - }); - return results; - }, - /* - * Flatten all values of an object into an array, marking each first element of - * each group with a specific flag - * eg. - * flattenAndFlagFirst({ - * 'devs': [ - * {name: 'Tim', category: 'dev'}, - * {name: 'Vincent', category: 'dev'}, - * {name: 'AlexS', category: 'dev'} - * ], - * 'sales': [ - * {name: 'Ben', category: 'sales'}, - * {name: 'Jeremy', category: 'sales'}, - * {name: 'AlexK', category: 'sales'} - * ] - * , 'isTop'); - * => - * [ - * {name: 'Tim', category: 'dev', isTop: true}, - * {name: 'Vincent', category: 'dev', isTop: false}, - * {name: 'AlexS', category: 'dev', isTop: false}, - * {name: 'Ben', category: 'sales', isTop: true}, - * {name: 'Jeremy', category: 'sales', isTop: false}, - * {name: 'AlexK', category: 'sales', isTop: false} - * ] - * @param {object} object Object to flatten - * @param {string} flag Flag to set to true on first element of each group - * @return {array} - */ - flattenAndFlagFirst(object, flag) { - const values = this.values(object).map(collection => - collection.map((item, index) => { - // eslint-disable-next-line no-param-reassign - item[flag] = index === 0; - return item; - }) - ); - return this.flatten(values); - }, - /* - * Removes all empty strings, null, false and undefined elements array - * eg. - * compact([42, false, null, undefined, '', [], 'foo']); - * => - * [42, [], 'foo'] - * @param {array} array Array to compact - * @return {array} - */ - compact(array) { - const results = []; - array.forEach(value => { - if (!value) { - return; - } - results.push(value); - }); - return results; - }, - /* - * Returns the highlighted value of the specified key in the specified object. - * If no highlighted value is available, will return the key value directly - * eg. - * getHighlightedValue({ - * _highlightResult: { - * text: { - * value: 'foo' - * } - * }, - * text: 'foo' - * }, 'text'); - * => - * 'foo' - * @param {object} object Hit object returned by the Algolia API - * @param {string} property Object key to look for - * @return {string} - **/ - getHighlightedValue(object, property) { - if ( - object._highlightResult && - object._highlightResult.hierarchy_camel && - object._highlightResult.hierarchy_camel[property] && - object._highlightResult.hierarchy_camel[property].matchLevel && - object._highlightResult.hierarchy_camel[property].matchLevel !== 'none' && - object._highlightResult.hierarchy_camel[property].value - ) { - return object._highlightResult.hierarchy_camel[property].value; - } - if ( - object._highlightResult && - object._highlightResult && - object._highlightResult[property] && - object._highlightResult[property].value - ) { - return object._highlightResult[property].value; - } - return object[property]; - }, - /* - * Returns the snippeted value of the specified key in the specified object. - * If no highlighted value is available, will return the key value directly. - * Will add starting and ending ellipsis (…) if we detect that a sentence is - * incomplete - * eg. - * getSnippetedValue({ - * _snippetResult: { - * text: { - * value: 'This is an unfinished sentence' - * } - * }, - * text: 'This is an unfinished sentence' - * }, 'text'); - * => - * 'This is an unfinished sentence…' - * @param {object} object Hit object returned by the Algolia API - * @param {string} property Object key to look for - * @return {string} - **/ - getSnippetedValue(object, property) { - if ( - !object._snippetResult || - !object._snippetResult[property] || - !object._snippetResult[property].value - ) { - return object[property]; - } - let snippet = object._snippetResult[property].value; - - if (snippet[0] !== snippet[0].toUpperCase()) { - snippet = `…${snippet}`; - } - if (['.', '!', '?'].indexOf(snippet[snippet.length - 1]) === -1) { - snippet = `${snippet}…`; - } - return snippet; - }, - /* - * Deep clone an object. - * Note: This will not clone functions and dates - * @param {object} object Object to clone - * @return {object} - */ - deepClone(object) { - return JSON.parse(JSON.stringify(object)); - }, -}; - -export default utils;