Skip to content

Commit

Permalink
Improvement: algolia search (#104)
Browse files Browse the repository at this point in the history
* perf: algolia search

* feat: add classes for algolia search

* refactor: remove link from my website
  • Loading branch information
nsdonato authored Mar 19, 2024
1 parent 8ba4564 commit 844260f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 56 deletions.
28 changes: 28 additions & 0 deletions components/sidebar-menu/sidebar-details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use client'

import { usePathname } from 'next/navigation'

import { cn } from '@/lib/utils'

type SidebarDetailProps = {
name: string
children: React.ReactNode
}

export const SidebarDetails = ({ name, children }: SidebarDetailProps) => {
const pathname = usePathname()

return (
<details>
<summary
className={cn({
'selected-menu':
name.toLowerCase().includes(pathname.split('/')[2]) ||
pathname === '/',
})}>
{name}
</summary>
{children}
</details>
)
}
8 changes: 5 additions & 3 deletions components/sidebar-menu/sidebar-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { usePathname } from 'next/navigation'

import { getMenu } from '@/lib/mdx/get-menu'

import { SidebarDetails } from './sidebar-details'
import LinkWrapper from './sidebar-selected'

type SidebarMenuProps = {
Expand All @@ -17,8 +20,7 @@ export const SidebarMenu = async ({ className }: SidebarMenuProps) => {
</li>
{menu.map(menuItem => (
<li key={menuItem.name}>
<details>
<summary>{menuItem.name}</summary>
<SidebarDetails name={menuItem.name}>
<ul className='grid gap-1'>
{menuItem.items.map((item, index) => {
return (
Expand All @@ -32,7 +34,7 @@ export const SidebarMenu = async ({ className }: SidebarMenuProps) => {
)
})}
</ul>
</details>
</SidebarDetails>
</li>
))}
</ul>
Expand Down
32 changes: 16 additions & 16 deletions components/sidebar-menu/sidebar-selected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import { usePathname } from 'next/navigation'
import { cn } from '@/lib/utils'

type LinkWrapperProps = {
href: string
children: React.ReactNode
className?: string
href: string
children: React.ReactNode
className?: string
}

export default function LinkWrapper({
href,
children,
className,
href,
children,
className,
}: LinkWrapperProps) {
const pathname = usePathname()
const pathname = usePathname()

return (
<Link
href={href}
className={cn(className, {
'border border-separate': pathname === href,
})}>
{children}
</Link>
)
return (
<Link
href={href}
className={cn(className, {
'border border-separate selected-submenu': pathname === href,
})}>
{children}
</Link>
)
}
19 changes: 0 additions & 19 deletions components/sidebar-menu/sidebar-submenu-item.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions components/sidebar-menu/test/sidebar-submenu-item.test.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions docs/frontend/streamers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ submenu:
url: 'https://www.twitch.tv/vamoacodear'
- type: 'Ig'
url: 'https://www.instagram.com/vamoacodear'
- type: 'Web'
url: 'https://vamoacodear.com.ar/'
- type: 'Discord'
url: 'https://discord.gg/JYnKadCSkV'
- type: 'X'
Expand Down

0 comments on commit 844260f

Please sign in to comment.