mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-20 23:44:46 +12:00
fix(guide): sidebar types
This commit is contained in:
parent
0928c8f6ff
commit
b35b935679
1 changed files with 10 additions and 10 deletions
|
@ -6,8 +6,15 @@ import { usePathname } from 'next/navigation';
|
|||
import { Section } from './Section';
|
||||
import { useNav } from '~/contexts/nav';
|
||||
|
||||
function transformItemsByCategory(allContents: any[]) {
|
||||
return allContents.reduce((accumulator: any, content) => {
|
||||
const items = allContents.map((content) => ({
|
||||
title: content.title,
|
||||
category: content.category,
|
||||
slug: content.slug,
|
||||
href: content.url,
|
||||
}));
|
||||
|
||||
function transformItemsByCategory(allContents: typeof items) {
|
||||
return allContents.reduce<Record<string, typeof items>>((accumulator: any, content) => {
|
||||
if (!accumulator[content.category]) {
|
||||
accumulator[content.category] = [];
|
||||
}
|
||||
|
@ -17,13 +24,6 @@ function transformItemsByCategory(allContents: any[]) {
|
|||
}, {});
|
||||
}
|
||||
|
||||
const items = allContents.map((content) => ({
|
||||
title: content.title,
|
||||
category: content.category,
|
||||
slug: content.slug,
|
||||
href: content.url,
|
||||
}));
|
||||
|
||||
const itemsByCategory = transformItemsByCategory(items);
|
||||
|
||||
export function Sidebar() {
|
||||
|
@ -38,7 +38,7 @@ export function Sidebar() {
|
|||
key={`${category}-${idx}`}
|
||||
title={category}
|
||||
>
|
||||
{itemsByCategory[category].map((member, index) => (
|
||||
{itemsByCategory[category]?.map((member, index) => (
|
||||
<Link
|
||||
className={`dark:border-dark-100 border-light-800 focus:ring-width-2 focus:ring-blurple ml-5 flex flex-col border-l p-[5px] pl-6 outline-0 focus:rounded focus:border-0 focus:ring ${
|
||||
decodeURIComponent(pathname ?? '') === member.href
|
||||
|
|
Loading…
Reference in a new issue