mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
feat: allow search by tags
This commit is contained in:
@@ -36,7 +36,13 @@ function resolveIcon(item: keyof ApiItemKind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CmdKDialog({ currentPackageName }: { currentPackageName?: string | undefined }) {
|
export function CmdKDialog({
|
||||||
|
currentPackageName,
|
||||||
|
currentVersion,
|
||||||
|
}: {
|
||||||
|
currentPackageName?: string | undefined;
|
||||||
|
currentVersion?: string | undefined;
|
||||||
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const dialog = useCmdK();
|
const dialog = useCmdK();
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
@@ -94,13 +100,13 @@ export function CmdKDialog({ currentPackageName }: { currentPackageName?: string
|
|||||||
}, [dialog!.open]);
|
}, [dialog!.open]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const searchDoc = async (searchString: string) => {
|
const searchDoc = async (searchString: string, version: string) => {
|
||||||
const res = await client.index(`${currentPackageName}-main`).search(searchString, { limit: 5 });
|
const res = await client.index(`${currentPackageName}-${version}`).search(searchString, { limit: 5 });
|
||||||
setSearchResults(res.hits);
|
setSearchResults(res.hits);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (search && currentPackageName) {
|
if (search && currentPackageName) {
|
||||||
void searchDoc(search);
|
void searchDoc(search, currentVersion?.replaceAll('.', '-') ?? 'main');
|
||||||
} else {
|
} else {
|
||||||
setSearchResults([]);
|
setSearchResults([]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ export function SidebarLayout({
|
|||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
<CmdKDialog currentPackageName={packageName} />
|
<CmdKDialog currentPackageName={packageName} currentVersion={branchName} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user