mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
fix(guide): sidebar types
This commit is contained in:
@@ -6,8 +6,15 @@ import { usePathname } from 'next/navigation';
|
|||||||
import { Section } from './Section';
|
import { Section } from './Section';
|
||||||
import { useNav } from '~/contexts/nav';
|
import { useNav } from '~/contexts/nav';
|
||||||
|
|
||||||
function transformItemsByCategory(allContents: any[]) {
|
const items = allContents.map((content) => ({
|
||||||
return allContents.reduce((accumulator: any, 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]) {
|
if (!accumulator[content.category]) {
|
||||||
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);
|
const itemsByCategory = transformItemsByCategory(items);
|
||||||
|
|
||||||
export function Sidebar() {
|
export function Sidebar() {
|
||||||
@@ -38,7 +38,7 @@ export function Sidebar() {
|
|||||||
key={`${category}-${idx}`}
|
key={`${category}-${idx}`}
|
||||||
title={category}
|
title={category}
|
||||||
>
|
>
|
||||||
{itemsByCategory[category].map((member, index) => (
|
{itemsByCategory[category]?.map((member, index) => (
|
||||||
<Link
|
<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 ${
|
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
|
decodeURIComponent(pathname ?? '') === member.href
|
||||||
|
|||||||
Reference in New Issue
Block a user