17 lines
391 B
TypeScript
17 lines
391 B
TypeScript
/**
|
|
* 搜索索引转换器
|
|
* @param hit 搜索条目
|
|
* @returns 转换后的搜索条目视图模型
|
|
*
|
|
* ---
|
|
* @example
|
|
* const view = toSearchItemView(item, 'products');
|
|
*/
|
|
export function toSearchItemView<T extends MeiliSearchItemType>(
|
|
item: MeiliIndexMap[T],
|
|
type: T
|
|
): SearchItemView {
|
|
const converter = converters[type];
|
|
return converter ? converter(item) : null;
|
|
}
|