mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-09 21:07:49 +00:00
feat: add search to author pages
This commit is contained in:
@@ -30,9 +30,13 @@ for (const picMapItem of unicornProfilePicMap) {
|
||||
export default async (req: VercelRequest, res: VercelResponse) => {
|
||||
// TODO: `pickdeep` only required fields
|
||||
const searchStr = req?.query?.query as string;
|
||||
const authorStr = req?.query?.authorId as string;
|
||||
if (!searchStr) return [];
|
||||
if (Array.isArray(searchStr)) return [];
|
||||
const posts = fuse.search(searchStr).map((item) => item.item as PostInfo);
|
||||
let posts = fuse.search(searchStr).map((item) => item.item as PostInfo);
|
||||
if (authorStr) {
|
||||
posts = posts.filter((post) => post.authors.includes(authorStr));
|
||||
}
|
||||
const unicornProfilePicMap = posts.flatMap((post) =>
|
||||
post.authorsMeta.map((authorMeta) => unicornProfilePicObj[authorMeta.id])
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user