mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
feat: reintroduce outline navigation
This commit is contained in:
22
apps/website/src/contexts/outline.tsx
Normal file
22
apps/website/src/contexts/outline.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
'use client';
|
||||
|
||||
import { createContext, useContext, useMemo, useState } from 'react';
|
||||
import type { PropsWithChildren, Dispatch, SetStateAction } from 'react';
|
||||
import type { TableOfContentsSerialized } from '~/components/TableOfContentItems';
|
||||
|
||||
export const OutlineContext = createContext<{
|
||||
members: TableOfContentsSerialized[] | null | undefined;
|
||||
setMembers: Dispatch<SetStateAction<TableOfContentsSerialized[] | null | undefined>>;
|
||||
}>({ members: undefined, setMembers: (_) => {} });
|
||||
|
||||
export const OutlineProvider = ({ children }: PropsWithChildren) => {
|
||||
const [members, setMembers] = useState<TableOfContentsSerialized[] | null | undefined>(undefined);
|
||||
|
||||
const value = useMemo(() => ({ members, setMembers }), [members]);
|
||||
|
||||
return <OutlineContext.Provider value={value}>{children}</OutlineContext.Provider>;
|
||||
};
|
||||
|
||||
export function useOutline() {
|
||||
return useContext(OutlineContext);
|
||||
}
|
||||
Reference in New Issue
Block a user