mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 11:47:23 +02:00
1 line
No EOL
11 KiB
JavaScript
1 line
No EOL
11 KiB
JavaScript
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["52375"],{27121:function(e,r,t){t.r(r),t.d(r,{metadata:()=>a,contentTitle:()=>u,default:()=>p,assets:()=>c,toc:()=>d,frontMatter:()=>s});var a=JSON.parse('{"id":"api/themes/theme-search-algolia","title":"\uD83D\uDCE6 theme-search-algolia","description":"This theme provides a @theme/SearchBar component that integrates with Algolia DocSearch easily. Combined with @docusaurus/theme-classic, it provides a very easy search integration. You can read more on search documentation.","source":"@site/docs/api/themes/theme-search-algolia.mdx","sourceDirName":"api/themes","slug":"/api/themes/@docusaurus/theme-search-algolia","permalink":"/docs/api/themes/@docusaurus/theme-search-algolia","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/edit/main/website/docs/api/themes/theme-search-algolia.mdx","tags":[],"version":"current","lastUpdatedBy":"S\xe9bastien Lorber","lastUpdatedAt":1729593657000,"sidebarPosition":4,"frontMatter":{"sidebar_position":4,"slug":"/api/themes/@docusaurus/theme-search-algolia"},"sidebar":"api","previous":{"title":"\uD83D\uDCE6 theme-live-codeblock","permalink":"/docs/api/themes/@docusaurus/theme-live-codeblock"},"next":{"title":"\uD83D\uDCE6 theme-mermaid","permalink":"/docs/api/themes/@docusaurus/theme-mermaid"}}'),n=t("24246"),o=t("80980"),i=t("15398"),l=t("58636");let s={sidebar_position:4,slug:"/api/themes/@docusaurus/theme-search-algolia"},u="\uD83D\uDCE6 theme-search-algolia",c={},d=[];function h(e){let r={a:"a",admonition:"admonition",code:"code",h1:"h1",header:"header",p:"p",pre:"pre",...(0,o.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.header,{children:(0,n.jsx)(r.h1,{id:"-theme-search-algolia",children:"\uD83D\uDCE6 theme-search-algolia"})}),"\n",(0,n.jsxs)(r.p,{children:["This theme provides a ",(0,n.jsx)(r.code,{children:"@theme/SearchBar"})," component that integrates with Algolia DocSearch easily. Combined with ",(0,n.jsx)(r.code,{children:"@docusaurus/theme-classic"}),", it provides a very easy search integration. You can read more on ",(0,n.jsx)(r.a,{href:"/docs/search",children:"search"})," documentation."]}),"\n",(0,n.jsxs)(i.Z,{groupId:"npm2yarn",children:[(0,n.jsx)(l.Z,{value:"npm",children:(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-bash",children:"npm install --save @docusaurus/theme-search-algolia\n"})})}),(0,n.jsx)(l.Z,{value:"yarn",label:"Yarn",children:(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-bash",children:"yarn add @docusaurus/theme-search-algolia\n"})})}),(0,n.jsx)(l.Z,{value:"pnpm",label:"pnpm",children:(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-bash",children:"pnpm add @docusaurus/theme-search-algolia\n"})})})]}),"\n",(0,n.jsxs)(r.p,{children:["This theme also adds search page available at ",(0,n.jsx)(r.code,{children:"/search"})," (as swizzlable ",(0,n.jsx)(r.code,{children:"SearchPage"})," component) path with OpenSearch support. You can change this default path via ",(0,n.jsx)(r.code,{children:"themeConfig.algolia.searchPagePath"}),". Use ",(0,n.jsx)(r.code,{children:"false"})," to disable search page."]}),"\n",(0,n.jsx)(r.admonition,{type:"tip",children:(0,n.jsxs)(r.p,{children:["If you have installed ",(0,n.jsx)(r.code,{children:"@docusaurus/preset-classic"}),", you don't need to install it as a dependency."]})})]})}function p(e={}){let{wrapper:r}={...(0,o.a)(),...e.components};return r?(0,n.jsx)(r,{...e,children:(0,n.jsx)(h,{...e})}):h(e)}},58636:function(e,r,t){t.d(r,{Z:()=>i});var a=t("24246");t("27378");var n=t("90496");let o="tabItem_pnkT";function i(e){var r=e.children,t=e.hidden,i=e.className;return(0,a.jsx)("div",{role:"tabpanel",className:(0,n.Z)(o,i),hidden:t,children:r})}},15398:function(e,r,t){t.d(r,{Z:()=>S});var a=t("24246"),n=t("27378"),o=t("90496"),i=t("54947"),l=t("3620"),s=t("844"),u=t("97486"),c=t("32263"),d=t("16971");function h(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=Array(r);t<r;t++)a[t]=e[t];return a}function p(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t,a,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),!r||o.length!==r);i=!0);}catch(e){l=!0,a=e}finally{try{!i&&null!=n.return&&n.return()}finally{if(l)throw a}}return o}}(e,r)||function(e,r){if(e){if("string"==typeof e)return h(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return h(e,r)}}(e,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var r,t;return null!==(t=null===(r=n.Children.toArray(e).filter(function(e){return"\n"!==e}).map(function(e){var r,t;if(!e||(0,n.isValidElement)(e)&&(r=e.props)&&(void 0===r?"undefined":(t=r)&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)=="object"&&"value"in r)return e;throw Error("Docusaurus error: Bad <Tabs> child <".concat("string"==typeof e.type?e.type:e.type.name,'>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.'))}))||void 0===r?void 0:r.filter(Boolean))&&void 0!==t?t:[]}function m(e){var r=e.value;return e.tabValues.some(function(e){return e.value===r})}var b=t("71607");let v="tabList_Qoir",y="tabItem_AQgk";function g(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(r){var a,n,o;a=e,n=r,o=t[r],n in a?Object.defineProperty(a,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[n]=o})}return e}function j(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t.push.apply(t,a)}return t})(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}function O(e){var r=e.className,t=e.block,n=e.selectedValue,l=e.selectValue,s=e.tabValues,u=[],c=(0,i.o5)().blockElementScrollPositionUntilNextRender,d=function(e){var r=e.currentTarget,t=s[u.indexOf(r)].value;t!==n&&(c(r),l(t))},h=function(e){var r=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":var t,a=u.indexOf(e.currentTarget)+1;r=null!==(t=u[a])&&void 0!==t?t:u[0];break;case"ArrowLeft":var n,o=u.indexOf(e.currentTarget)-1;r=null!==(n=u[o])&&void 0!==n?n:u[u.length-1]}null==r||r.focus()};return(0,a.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,o.Z)("tabs",{"tabs--block":t},r),children:s.map(function(e){var r=e.value,t=e.label,i=e.attributes;return(0,a.jsx)("li",j(g({role:"tab",tabIndex:n===r?0:-1,"aria-selected":n===r,ref:function(e){return u.push(e)},onKeyDown:h,onClick:d},i),{className:(0,o.Z)("tabs__item",y,null==i?void 0:i.className,{"tabs__item--active":n===r}),children:null!=t?t:r}),r)})})}function x(e){var r=e.lazy,t=e.children,i=e.selectedValue,l=(Array.isArray(t)?t:[t]).filter(Boolean);if(r){var s=l.find(function(e){return e.props.value===i});return s?(0,n.cloneElement)(s,{className:(0,o.Z)("margin-top--md",s.props.className)}):null}return(0,a.jsx)("div",{className:"margin-top--md",children:l.map(function(e,r){return(0,n.cloneElement)(e,{key:r,hidden:e.props.value!==i})})})}function w(e){var r=function(e){var r,t,a,o,i,h,b,v,y,g,j,O,x,w,S=e.defaultValue,P=e.queryString,k=e.groupId;var I=(t=(r=e).values,a=r.children,(0,n.useMemo)(function(){var e=null!=t?t:f(a).map(function(e){var r=e.props;return{value:r.value,label:r.label,attributes:r.attributes,default:r.default}});return!function(e){var r=(0,c.lx)(e,function(e,r){return e.value===r.value});if(r.length>0)throw Error('Docusaurus error: Duplicate values "'.concat(r.map(function(e){return e.value}).join(", "),'" found in <Tabs>. Every value needs to be unique.'))}(e),e},[t,a])),T=p((0,n.useState)(function(){return function(e){var r,t=e.defaultValue,a=e.tabValues;if(0===a.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(t){if(!m({value:t,tabValues:a}))throw Error('Docusaurus error: The <Tabs> has a defaultValue "'.concat(t,'" but none of its children has the corresponding value. Available values are: ').concat(a.map(function(e){return e.value}).join(", "),". If you intend to show no default tab, use defaultValue={null} instead."));return t}var n=null!==(r=a.find(function(e){return e.default}))&&void 0!==r?r:a[0];if(!n)throw Error("Unexpected error: 0 tabValues");return n.value}({defaultValue:S,tabValues:I})}),2),V=T[0],E=T[1];var D=p((i=(o={queryString:void 0!==P&&P,groupId:k}).queryString,h=o.groupId,b=(0,l.k6)(),v=function(e){var r=e.queryString,t=void 0!==r&&r,a=e.groupId;if("string"==typeof t)return t;if(!1===t)return null;if(!0===t&&!a)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return null!=a?a:null}({queryString:void 0!==i&&i,groupId:h}),[(0,u._X)(v),(0,n.useCallback)(function(e){if(!!v){var r,t,a=new URLSearchParams(b.location.search);a.set(v,e),b.replace((r=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(r){var a,n,o;a=e,n=r,o=t[r],n in a?Object.defineProperty(a,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[n]=o})}return e}({},b.location),t=(t={search:a.toString()},t),Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t.push.apply(t,a)}return t})(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}),r))}},[v,b])]),2),N=D[0],A=D[1];var C=p((g=(y=({groupId:k}).groupId)?"docusaurus.tab.".concat(y):null,O=(j=p((0,d.Nk)(g),2))[0],x=j[1],[O,(0,n.useCallback)(function(e){if(!!g)x.set(e)},[g,x])]),2),Z=C[0],q=C[1];var _=m({value:w=null!=N?N:Z,tabValues:I})?w:null;return(0,s.Z)(function(){_&&E(_)},[_]),{selectedValue:V,selectValue:(0,n.useCallback)(function(e){if(!m({value:e,tabValues:I}))throw Error("Can't select invalid tab value=".concat(e));E(e),A(e),q(e)},[A,q,I]),tabValues:I}}(e);return(0,a.jsxs)("div",{className:(0,o.Z)("tabs-container",v),children:[(0,a.jsx)(O,g({},r,e)),(0,a.jsx)(x,g({},r,e))]})}function S(e){var r=(0,b.Z)();return(0,a.jsx)(w,j(g({},e),{children:f(e.children)}),String(r))}},80980:function(e,r,t){t.d(r,{Z:function(){return l},a:function(){return i}});var a=t(27378);let n={},o=a.createContext(n);function i(e){let r=a.useContext(o);return a.useMemo(function(){return"function"==typeof e?e(r):{...r,...e}},[r,e])}function l(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:i(e.components),a.createElement(o.Provider,{value:r},e.children)}}}]); |