docs(nxdev): update algolia types (#11379)
This commit is contained in:
parent
8797915020
commit
15200964ef
@ -1,15 +1,25 @@
|
||||
import { DocSearchModal, useDocSearchKeyboardEvents } from '@docsearch/react';
|
||||
import {
|
||||
InternalDocSearchHit,
|
||||
StoredDocSearchHit,
|
||||
} from '@docsearch/react/dist/esm/types';
|
||||
import { SearchIcon } from '@heroicons/react/solid';
|
||||
import Head from 'next/head';
|
||||
import Link from 'next/link';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { ReactNode, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
|
||||
const ACTION_KEY_DEFAULT = ['Ctrl ', 'Control'];
|
||||
const ACTION_KEY_APPLE = ['⌘', 'Command'];
|
||||
|
||||
function Hit({ hit, children }) {
|
||||
function Hit({
|
||||
hit,
|
||||
children,
|
||||
}: {
|
||||
hit: InternalDocSearchHit | StoredDocSearchHit;
|
||||
children: ReactNode;
|
||||
}): JSX.Element {
|
||||
return (
|
||||
<Link href={hit.url}>
|
||||
<a>{children}</a>
|
||||
@ -17,7 +27,7 @@ function Hit({ hit, children }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function AlgoliaSearch() {
|
||||
export function AlgoliaSearch(): JSX.Element {
|
||||
const router = useRouter();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const searchButtonRef = useRef<HTMLButtonElement>(null);
|
||||
@ -33,9 +43,9 @@ export function AlgoliaSearch() {
|
||||
}, [setIsOpen]);
|
||||
|
||||
const handleInput = useCallback(
|
||||
(e) => {
|
||||
(event: KeyboardEvent) => {
|
||||
setIsOpen(true);
|
||||
setInitialQuery(e.key);
|
||||
setInitialQuery(event.key);
|
||||
},
|
||||
[setIsOpen, setInitialQuery]
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user