chore: backend fix

feat/cmd-k
Arik Chakma 2 years ago
parent b707aa02d8
commit 4d7cada25c
  1. 17
      src/components/CommandMenu/CommandMenu.tsx
  2. 16
      src/pages/pages.json.astro

@ -25,10 +25,12 @@ export function CommandMenu() {
<input <input
type="text" type="text"
value={searchedText} value={searchedText}
class={ className="w-full rounded-t-md border-b p-4 text-sm focus:bg-gray-50 focus:outline-0"
'w-full rounded-t-md border-b p-4 text-sm focus:bg-gray-50 focus:outline-0'
}
placeholder="Search anywhere .." placeholder="Search anywhere .."
onInput={(e) => {
const value = (e.target as HTMLInputElement).value.trim();
setSearchedText(value);
}}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'ArrowDown') { if (e.key === 'ArrowDown') {
const canGoNext = activeCounter < pages.length - 1; const canGoNext = activeCounter < pages.length - 1;
@ -54,9 +56,12 @@ export function CommandMenu() {
onMouseOver={() => setActiveCounter(counter)} onMouseOver={() => setActiveCounter(counter)}
href={page.href} href={page.href}
> >
{searchedText && (
{searchedText && <span class='text-gray-400 mr-2'>{ page.group }</span> } <span class="mr-2 text-gray-400">{page.group}</span>
{!searchedText && <span class='text-gray-400 mr-2'>ICON</span> } )}
{!searchedText && (
<span class="mr-2 text-gray-400">ICON</span>
)}
{page.title} {page.title}
</a> </a>
))} ))}

@ -9,24 +9,28 @@ const videos = await getAllVideos();
const roadmaps = await getRoadmapsByTag('roadmap'); const roadmaps = await getRoadmapsByTag('roadmap');
const bestPractices = await getAllBestPractices(); const bestPractices = await getAllBestPractices();
const formattedData = { const formattedData = [
Roadmaps: roadmaps.map((roadmap) => ({ ...roadmaps.map((roadmap) => ({
url: `/${roadmap.id}`, url: `/${roadmap.id}`,
title: roadmap.frontmatter.briefTitle, title: roadmap.frontmatter.briefTitle,
group: 'Roadmaps',
})), })),
'Best Practices': bestPractices.map((bestPractice) => ({ ...bestPractices.map((bestPractice) => ({
url: `/${bestPractice.id}`, url: `/${bestPractice.id}`,
title: bestPractice.frontmatter.briefTitle, title: bestPractice.frontmatter.briefTitle,
group: 'Best Practices',
})), })),
Guides: guides.map((guide) => ({ ...guides.map((guide) => ({
url: `/${guide.id}`, url: `/${guide.id}`,
title: guide.frontmatter.title, title: guide.frontmatter.title,
group: 'Guides',
})), })),
Videos: videos.map((guide) => ({ ...videos.map((guide) => ({
url: `/${guide.id}`, url: `/${guide.id}`,
title: guide.frontmatter.title, title: guide.frontmatter.title,
group: 'Videos',
})), })),
}; ];
--- ---
{JSON.stringify(formattedData)} {JSON.stringify(formattedData)}

Loading…
Cancel
Save