Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: algolia search #104

Merged
merged 5 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading