Skip to content

Commit

Permalink
feat(kbar): make TILs searchable
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Dec 18, 2023
1 parent 44e8fc5 commit bdc3fbe
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/shared/components/kbar/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactNode } from 'react'
import { useRouter } from 'next/navigation'
import { KBarProvider, Action } from 'kbar'
import { useTheme } from 'next-themes'
import { allPosts, allProjects } from 'contentlayer/generated'
import { allPosts, allProjects, allTILs } from 'contentlayer/generated'
import {
Article,
Briefcase,
Expand Down Expand Up @@ -147,6 +147,19 @@ export function CustomKBarProvider({ children }: { children: ReactNode }) {
section: 'Blog',
perform: () => push(`/blog/post/${id}`)
}))
const tilsAsAction: Action[] = allTILs.map(til => ({
id: slug(til.title),
name: til.title,
icon: <Notebook weight="duotone" />,
keywords: til.tags
.map(tag => tag.trim())
.toString()
.replaceAll(',', ' '),
parent: 'search-posts',
subtitle: til.description,
section: 'Blog',
perform: () => push(`/blog/til#${slug(til.title)}`)
}))

const blogActions: Action[] = [
{
Expand Down Expand Up @@ -201,7 +214,8 @@ export function CustomKBarProvider({ children }: { children: ReactNode }) {
shortcut: ['b', 's'],
icon: <MagnifyingGlass weight="duotone" />
},
...postsAsAction
...postsAsAction,
...tilsAsAction
]

const personalLinksActions: Action[] = [
Expand Down

0 comments on commit bdc3fbe

Please sign in to comment.