@@ -10,9 +10,11 @@ import {
1010 CommandInput ,
1111 CommandItem ,
1212 CommandList ,
13+ CommandSeparator ,
1314} from "@/components/ui/command" ;
1415import { Button } from "@/components/ui/button" ;
1516
17+ import { cn } from "@/utils/cn" ;
1618import { SearchIcon } from "lucide-react" ;
1719import { getDocsByFolder } from "@/utils/docs" ;
1820
@@ -54,23 +56,42 @@ const SearchDocs = () => {
5456 < CommandInput placeholder = "Search" />
5557 < CommandList >
5658 < CommandEmpty > No results found.</ CommandEmpty >
57- { Object . entries ( docsByFolder ) . map ( ( [ folder , docs ] ) => (
58- < CommandGroup key = { folder } heading = { folder } className = "my-2" >
59- { docs . map ( ( doc ) => (
60- < CommandItem
61- key = { doc . _meta . path }
62- onSelect = { ( ) => {
63- router . push ( `/docs/${ doc . folder } /${ doc . _meta . path } ` ) ;
64- setOpen ( false ) ;
65- } }
66- >
67- < span className = "font-medium" > { doc . title } </ span >
68- < span className = "max-w-110 truncate text-xs text-neutral-600 dark:text-neutral-400" >
69- { doc . description }
70- </ span >
71- </ CommandItem >
72- ) ) }
73- </ CommandGroup >
59+ { Object . entries ( docsByFolder ) . map ( ( [ folder , docs ] , index , array ) => (
60+ < div key = { folder } >
61+ < CommandGroup heading = { folder } className = "my-1" >
62+ { docs . map ( ( doc ) => (
63+ < CommandItem
64+ key = { doc . _meta . path }
65+ onSelect = { ( ) => {
66+ router . push ( `/docs/${ doc . folder } /${ doc . _meta . path } ` ) ;
67+ setOpen ( false ) ;
68+ } }
69+ >
70+ < span className = "font-medium" > { doc . title } </ span >
71+ < span className = "max-w-110 truncate text-xs text-neutral-600 dark:text-neutral-400" >
72+ { doc . description }
73+ </ span >
74+ { doc . category && (
75+ < div className = "mt-1 flex items-center space-x-1" >
76+ { doc . category . map ( ( cat ) => (
77+ < span
78+ key = { cat }
79+ className = { cn (
80+ "bg-neutral-100 dark:bg-neutral-800" ,
81+ "border border-neutral-300 dark:border-neutral-700" ,
82+ "rounded-full px-2 py-0.5 text-xs tracking-tight text-neutral-600 dark:text-neutral-300" ,
83+ ) }
84+ >
85+ { cat }
86+ </ span >
87+ ) ) }
88+ </ div >
89+ ) }
90+ </ CommandItem >
91+ ) ) }
92+ </ CommandGroup >
93+ { index < array . length - 1 && < CommandSeparator /> }
94+ </ div >
7495 ) ) }
7596 </ CommandList >
7697 </ CommandDialog >
0 commit comments