Skip to content

Commit

Permalink
docs(nxdev): update algolia docsearch version (#9614)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcabanes committed Mar 30, 2022
1 parent e22bdd0 commit 42f1c73
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
24 changes: 16 additions & 8 deletions nx-dev/feature-search/src/lib/algolia-search.tsx
Expand Up @@ -9,10 +9,9 @@ import { createPortal } from 'react-dom';
const ACTION_KEY_DEFAULT = ['Ctrl ', 'Control'];
const ACTION_KEY_APPLE = ['⌘', 'Command'];

// TODO@ben: remove replace pattern when Algolia is updated
function Hit({ hit, children }) {
return (
<Link href={hit.url.replace(/\/(p|l)\/(a|r|n)/, '')}>
<Link href={hit.url}>
<a>{children}</a>
</Link>
);
Expand All @@ -22,7 +21,7 @@ export function AlgoliaSearch() {
const router = useRouter();
const [isOpen, setIsOpen] = useState(false);
const searchButtonRef = useRef<HTMLButtonElement>(null);
const [initialQuery, setInitialQuery] = useState(null);
const [initialQuery, setInitialQuery] = useState('');
const [browserDetected, setBrowserDetected] = useState(false);
const [actionKey, setActionKey] = useState(ACTION_KEY_DEFAULT);

Expand Down Expand Up @@ -97,28 +96,37 @@ export function AlgoliaSearch() {
{isOpen &&
createPortal(
<DocSearchModal
// searchParameters={{
// facetFilters: ['language:en'],
// }}
initialQuery={initialQuery}
placeholder="Search documentation"
initialScrollY={window.scrollY}
onClose={handleClose}
indexName="nx"
apiKey="0c9c3fb22624056e7475eddcbcbfbe91"
appId="BH4D9OD16A"
navigator={{
navigate({ suggestionUrl }) {
navigate({ itemUrl }) {
setIsOpen(false);
router.push(suggestionUrl);
router.push(itemUrl);
},
}}
hitComponent={Hit}
transformItems={(items) => {
return items.map((item) => {
// We transform the absolute URL into a relative URL to
// leverage Next's preloading.
return items.map((item, index) => {
const a = document.createElement('a');
a.href = item.url;

const hash = a.hash === '#content-wrapper' ? '' : a.hash;

if (item.hierarchy?.lvl0) {
item.hierarchy.lvl0 = item.hierarchy.lvl0.replace(
/&amp;/g,
'&'
);
}

return {
...item,
url: `${a.pathname}${hash}`,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -269,7 +269,7 @@
}
},
"dependencies": {
"@docsearch/react": "1.0.0-alpha.27",
"@docsearch/react": "3.0.0",
"@headlessui/react": "^1.1.1",
"@heroicons/react": "^1.0.1",
"@monaco-editor/react": "^4.3.1",
Expand Down
51 changes: 30 additions & 21 deletions yarn.lock
Expand Up @@ -2,6 +2,25 @@
# yarn lockfile v1


"@algolia/autocomplete-core@1.5.2":
version "1.5.2"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.5.2.tgz#ec0178e07b44fd74a057728ac157291b26cecf37"
integrity sha512-DY0bhyczFSS1b/CqJlTE/nQRtnTAHl6IemIkBy0nEWnhDzRDdtdx4p5Uuk3vwAFxwEEgi1WqKwgSSMx6DpNL4A==
dependencies:
"@algolia/autocomplete-shared" "1.5.2"

"@algolia/autocomplete-preset-algolia@1.5.2":
version "1.5.2"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.5.2.tgz#36c5638cc6dba6ea46a86e5a0314637ca40a77ca"
integrity sha512-3MRYnYQFJyovANzSX2CToS6/5cfVjbLLqFsZTKcvF3abhQzxbqwwaMBlJtt620uBUOeMzhdfasKhCc40+RHiZw==
dependencies:
"@algolia/autocomplete-shared" "1.5.2"

"@algolia/autocomplete-shared@1.5.2":
version "1.5.2"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.5.2.tgz#e157f9ad624ab8fd940ff28bd2094cdf199cdd79"
integrity sha512-ylQAYv5H0YKMfHgVWX0j0NmL8XBcAeeeVQUmppnnMtzDbDnca6CzhKj3Q8eF9cHCgcdTDdb5K+3aKyGWA0obug==

"@algolia/cache-browser-local-storage@4.13.0":
version "4.13.0"
resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.13.0.tgz#f8aa4fe31104b19d616ea392f9ed5c2ea847d964"
Expand Down Expand Up @@ -1804,19 +1823,19 @@
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==

"@docsearch/css@^1.0.0-alpha.27":
version "1.0.0-alpha.28"
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-1.0.0-alpha.28.tgz#c8a2cd8c1bb3a6855c51892e9dbdab5d42fe6e23"
integrity sha512-1AhRzVdAkrWwhaxTX6/R7SnFHz8yLz1W8I/AldlTrfbNvZs9INk1FZiEFTJdgHaP68nhgQNWSGlQiDiI3y2RYg==
"@docsearch/css@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.0.0.tgz#fe57b474802ffd706d3246eab25d52fac8aa3698"
integrity sha512-1kkV7tkAsiuEd0shunYRByKJe3xQDG2q7wYg24SOw1nV9/2lwEd4WrUYRJC/ukGTl2/kHeFxsaUvtiOy0y6fFA==

"@docsearch/react@1.0.0-alpha.27":
version "1.0.0-alpha.27"
resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-1.0.0-alpha.27.tgz#eae61d648ddc3667c5dee82c4cd9d47bf35a3c85"
integrity sha512-jcgUHZsrNNRsaVsplqKhXWheh4VzRTCdhsPuVhJMRvfsFUqXEPo/7kVt5xIybtOj9u+/FVdeSO+APJEE2rakYA==
"@docsearch/react@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.0.0.tgz#d02ebdc67573412185a6a4df13bc254c7c0da491"
integrity sha512-yhMacqS6TVQYoBh/o603zszIb5Bl8MIXuOc6Vy617I74pirisDzzcNh0NEaYQt50fVVR3khUbeEhUEWEWipESg==
dependencies:
"@docsearch/css" "^1.0.0-alpha.27"
"@francoischalifour/autocomplete-core" "^1.0.0-alpha.27"
"@francoischalifour/autocomplete-preset-algolia" "^1.0.0-alpha.27"
"@algolia/autocomplete-core" "1.5.2"
"@algolia/autocomplete-preset-algolia" "1.5.2"
"@docsearch/css" "3.0.0"
algoliasearch "^4.0.0"

"@emotion/cache@^10.0.27", "@emotion/cache@^10.0.9":
Expand Down Expand Up @@ -1936,16 +1955,6 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

"@francoischalifour/autocomplete-core@^1.0.0-alpha.27":
version "1.0.0-alpha.28"
resolved "https://registry.yarnpkg.com/@francoischalifour/autocomplete-core/-/autocomplete-core-1.0.0-alpha.28.tgz#6b9d8491288e77f831e9b345d461623b0d3f5005"
integrity sha512-rL9x+72btViw+9icfBKUJjZj87FgjFrD2esuTUqtj4RAX3s4AuVZiN8XEsfjQBSc6qJk31cxlvqZHC/BIyYXgg==

"@francoischalifour/autocomplete-preset-algolia@^1.0.0-alpha.27":
version "1.0.0-alpha.28"
resolved "https://registry.yarnpkg.com/@francoischalifour/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.0.0-alpha.28.tgz#a5ad7996f42e43e4acbb4e0010d663746d0e9997"
integrity sha512-bprfNmYt1opFUFEtD2XfY/kEsm13bzHQgU80uMjhuK0DJ914IjolT1GytpkdM6tJ4MBvyiJPP+bTtWO+BZ7c7w==

"@gar/promisify@^1.0.1", "@gar/promisify@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
Expand Down

1 comment on commit 42f1c73

@vercel
Copy link

@vercel vercel bot commented on 42f1c73 Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.