From 4d7cada25c636469ea9e2b22cd1b5b63b9c8333d Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Sat, 20 May 2023 18:44:07 +0600 Subject: [PATCH] chore: backend fix --- src/components/CommandMenu/CommandMenu.tsx | 17 +++++++++++------ src/pages/pages.json.astro | 16 ++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/components/CommandMenu/CommandMenu.tsx b/src/components/CommandMenu/CommandMenu.tsx index e19ef8b10..7aab90e5b 100644 --- a/src/components/CommandMenu/CommandMenu.tsx +++ b/src/components/CommandMenu/CommandMenu.tsx @@ -25,10 +25,12 @@ export function CommandMenu() { { + const value = (e.target as HTMLInputElement).value.trim(); + setSearchedText(value); + }} onKeyDown={(e) => { if (e.key === 'ArrowDown') { const canGoNext = activeCounter < pages.length - 1; @@ -54,9 +56,12 @@ export function CommandMenu() { onMouseOver={() => setActiveCounter(counter)} href={page.href} > - - {searchedText && { page.group } } - {!searchedText && ICON } + {searchedText && ( + {page.group} + )} + {!searchedText && ( + ICON + )} {page.title} ))} diff --git a/src/pages/pages.json.astro b/src/pages/pages.json.astro index f48bf15d6..d467d09b8 100644 --- a/src/pages/pages.json.astro +++ b/src/pages/pages.json.astro @@ -9,24 +9,28 @@ const videos = await getAllVideos(); const roadmaps = await getRoadmapsByTag('roadmap'); const bestPractices = await getAllBestPractices(); -const formattedData = { - Roadmaps: roadmaps.map((roadmap) => ({ +const formattedData = [ + ...roadmaps.map((roadmap) => ({ url: `/${roadmap.id}`, title: roadmap.frontmatter.briefTitle, + group: 'Roadmaps', })), - 'Best Practices': bestPractices.map((bestPractice) => ({ + ...bestPractices.map((bestPractice) => ({ url: `/${bestPractice.id}`, title: bestPractice.frontmatter.briefTitle, + group: 'Best Practices', })), - Guides: guides.map((guide) => ({ + ...guides.map((guide) => ({ url: `/${guide.id}`, title: guide.frontmatter.title, + group: 'Guides', })), - Videos: videos.map((guide) => ({ + ...videos.map((guide) => ({ url: `/${guide.id}`, title: guide.frontmatter.title, + group: 'Videos', })), -}; +]; --- {JSON.stringify(formattedData)}