mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
feat(website): add type field to search index to sort by (#10212)
This commit is contained in:
@@ -95,6 +95,7 @@ export function CmdK({ dependencies }: { readonly dependencies: string[] }) {
|
|||||||
q: searchString,
|
q: searchString,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
attributesToSearchOn: ['name'],
|
attributesToSearchOn: ['name'],
|
||||||
|
sort: ['type:asc'],
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
setSearchResults(result.results.flatMap((res) => res.hits));
|
setSearchResults(result.results.flatMap((res) => res.hits));
|
||||||
|
|||||||
@@ -66,7 +66,10 @@ try {
|
|||||||
await client.waitForTask(task.taskUid);
|
await client.waitForTask(task.taskUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
await client.index(index.index).addDocuments(index.data);
|
const searchIndex = client.index(index.index);
|
||||||
|
await searchIndex.updateSettings({ sortableAttributes: ['type'] });
|
||||||
|
|
||||||
|
await searchIndex.addDocuments(index.data);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export interface MemberJSON {
|
|||||||
name: string;
|
name: string;
|
||||||
path: string;
|
path: string;
|
||||||
summary: string | null;
|
summary: string | null;
|
||||||
|
type: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
let idx = 0;
|
let idx = 0;
|
||||||
@@ -89,6 +90,30 @@ export function tryResolveSummaryText(item: ApiDeclaredItem): string | null {
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum SearchOrderType {
|
||||||
|
Class,
|
||||||
|
Interface,
|
||||||
|
TypeAlias,
|
||||||
|
Function,
|
||||||
|
Enum,
|
||||||
|
Variable,
|
||||||
|
Event,
|
||||||
|
Method,
|
||||||
|
Property,
|
||||||
|
MethodSignature,
|
||||||
|
PropertySignature,
|
||||||
|
EnumMember,
|
||||||
|
Package,
|
||||||
|
Namespace,
|
||||||
|
IndexSignature,
|
||||||
|
CallSignature,
|
||||||
|
Constructor,
|
||||||
|
ConstructSignature,
|
||||||
|
EntryPoint,
|
||||||
|
Model,
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
export function visitNodes(item: ApiItem, tag: string) {
|
export function visitNodes(item: ApiItem, tag: string) {
|
||||||
const members: (MemberJSON & { id: number })[] = [];
|
const members: (MemberJSON & { id: number })[] = [];
|
||||||
|
|
||||||
@@ -111,6 +136,7 @@ export function visitNodes(item: ApiItem, tag: string) {
|
|||||||
kind: member.kind,
|
kind: member.kind,
|
||||||
summary: tryResolveSummaryText(member) ?? '',
|
summary: tryResolveSummaryText(member) ?? '',
|
||||||
path: generatePath(member.getHierarchy(), tag),
|
path: generatePath(member.getHierarchy(), tag),
|
||||||
|
type: SearchOrderType[member.kind as keyof typeof SearchOrderType],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user